# # Processes Process Management # #ps查看当前系统执行的线程列表, make an instantaneous state, not continuous state, continuous state need to use the top name to see more common parameters please use man ps to view PS # #显示所有进程详细信息ps aux ##-u show a user's process List Ps-f-u www-data #-C by name or command search process ps-c apache2 # #--sort based on process CPU usage descending, view top 5 processes-pcpu Express descending pcpu ascending PS aux--sort=-pc Pu | Head-5 ##-f the hierarchy of processes with a tree structure, parent-child process Ps-f--forest-c apache2 # #显示一个父进程的所有子进程ps-o pid,uname,comm-c apache2ps--ppid 2359 # #显示一个进程的所有线程-L parameter ps-p 3150-l # #显示进程的执行时间-o parameter Ps-e-o pid,comm,etime # #watch命令可以用来实时捕捉ps显示进程watch-N 1 ' ps-e-o pi D,UNAME,CMD,PMEM,PCPU--SORT=-PMEM,-PCPU | Head-15 ' # #jobs View the results of the execution of a process that is running in the background, + represents a current job, the minus table is a job after the current job, the JOBS-L option shows the Pid,jobs status of all tasks can be running, Stopped, Terminated, but if the task is terminated (kill), the shell removes the process identity of the task from the list known to the current shell environment; The Jobs command displays the task information that is running in the background or suspended in the current shell environment jobs # #查看后台运营的进程号jobs-P # #查看现在被终止或者退出的进程号jobs-N # #kill命令 terminating a foreground process can use CTRL + C-Key kill gets the process ID number via top or PS kill [-S signal |-P] [-a] process number ... # #发送指定的信号到相应进程. Not specifying a model will send Sigterm (15) to terminate the specified process. Close process number 12 process Kill # #等同于在前台运行PID为123的进程时按下Ctrl +c key Kill-2 1# #如果任无法终止该程序可用 "-kill" parameter, which sends a signal of Sigkill (9), will force the end process Kill-9 123 # #列出所有信号名称 # #HUP 1 terminal disconnection # #INT 2 interrupt (with Ctrl + C) # #QUIT 3 exit (with Ctrl + \) # #TERM 15 Terminate # #KILL 9 Force Abort # #CONT 18 Continue (FG/BG command) # #STOP 19 Pause ( With Ctrl + Z) kill-l # #得到指定信号的数值kill-L Kill # #杀死指定用户所有进程kill-u peidalinuxkill-9 $ (ps-ef | grep peidalinux) # #将后台中的命令调至前 The console continues to run the process 123 to the foreground to perform FG 123 # #将一个在后台暂停的命令, and then continues to run the corresponding process after the BG 123 # #该命令可以在你退出帐户/Shut down the terminal. Nohup is not hanging. The following output is redirected to the myout.file file nohup command > Myout.file 2>&1 & # #at: Schedule a task, perform a job at a specific time, and perform it at a specific time. # # Format: at hh:mm yyyy-mm-dd//hh (Hours): MM (min) YYYY (year)-mm (month)-DD (day) # #HH [am Pm]+d (day) days//hh (Hours) [am (a.m.) PM (PM)]+days (day) at 12:00 (time)//at command set 12:00 perform an operation #at>useradd AAA//Set Add user aaa#ctrl+d at command//exit at command #tail-f/etc/passwd//View/etc/ passwd file after 10 row whether to add a user AAA # #计划任务设定后, we can use the ATQ command to see the system does not perform the work task before execution. ATQ # #启动计划任务后, if you do not want to start a scheduled task, you can use the ATRM command to delete it. ATRM 1//Delete scheduled Task 1 # #pstree命令: Lists the current processes, along with their tree-structured format: pstree [Options] [Pid|user]pstree # #nice命令: Change the priority of program executionWeight application priority value range from -20~19, the smaller the number, the higher the priority. In general, the priority value of a normal application (the CPU Usage value) is 0, and if you have a high priority level for a common program, it will start and run faster. It is important to note that the normal user can only adjust the application's priority value between 0~19, only the superuser has the right to adjust the higher priority value (from -20~19). Nice [-N < priority >][--help][--version][command]nice-n 5 ls # #sleep命令: Causes the process to pause for a period of time Date;sleep 1m;date # #renice命令 The Renice command allows the user to modify the priority of a running process. Use the Renice command to adjust its precedence when the command executes. # #其中, the parameter number has the same meaning as number of the nice command. (1) The user can only use the Renice command for all of their processes. (2) The root user can use the Renice command on any process. (3) Only the root user can increase the priority of the process renice-5-P 5200 #PID为5200的进程nice设为-5 # #pmap命令用于显示一个或多个进程的内存状态. It reports the process's address space and memory state information #pmap PID pmap 20367 # #top Dynamic view of the process changes. Top # #crontab Task Scheduler # #基本格式: ##* * * * * command# #分 Day and Month command # #第1列表示分钟1 ~59 per minute with * or */1 # #第2列表示小时1 ~23 (0 means 0 points) # #第3列表示日期1 ~31# #第4列表示月份1 ~12# #第5列标识号星期0 (0 = Sunday) # #第6列要运行的命令crontab-E # #执行文字编辑器来设定时程表, the default text editor is VI, if you want to use a different text editor, first set the VISUAL Environment variables to specify the use of that text editor (e.g. setenv VISUAL Joe) Crontab-r # #删除目前的时程表 crontab-l # #列出目前的时程表 crontab file [-u user] ##-replace the current C with the specified file Rontab. #crontab文件的一些示例30 * * */usr/local/etc/rc.d/lighttpd Restart # #表示每晚的21:30 restart Apache.4 1,10,22 * */USR/LOCAL/ETC/RC.D/LIGHTTPD restart # 4:45 restart Apache on #表示每月1, 10, 22nd. 1 * * 6,0/usr/local/etc/rc.d/lighttpd restart # #表示每周六, Sunday 1:10 restart Apache. 0,30 18-23 * * */usr/local/etc/rc.d/lighttpd Restart # #表示在每天18: Restart Apache every 30 minutes between 00 and 23:00. * 23-7/1 * * * */usr/local/etc/rc.d/lighttpd Restart # #晚上11点到早上7点之间, restart Apache every hour
For more common daily operation scripts for Linux, please refer to: https://github.com/zhwj184/shell-work
Linux process Management Related commands summary