Linux process management

0) check bash running jobs by jobs


1) push  bash job background by bg, push forward by fg

2) top   

 https://www.booleanworld.com/guide-linux-top-command/

https://linuxaria.com/howto/understanding-the-top-command-on-linux

 

top - 07:56:54 up 1:22, 2 users, load average: 0.00, 0.01, 0.05    //load average of last min, 5 mins and 15 mins 

Tasks: 240 total, 2 running, 238 sleeping, 0 stopped, 0 zombie
%Cpu(s): 4.3 us, 1.3 sy, 0.0 ni, 94.3 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st    //us : user space , sy: system space , id: ideal , wa : waiting for IO  
KiB Mem: 1000196 total, 926708 used, 73488 free, 70084 buffers   // Mem
KiB Swap: 1046524 total, 431688 used, 614836 free. 196636 cached Mem    

PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND      //VIRT vertial memory, RES, resident memory, SHR, share memory
9 root 20 0 0 0 0 S 0.3 0.0 0:00.20 rcuos/0    // S for sleeping 
20 root 39 19 0 0 0 S 0.3 0.0 0:00.10 khugepaged
29 root 20 0 0 0 0 S 0.3 0.0 0:01.03 kworker/0:1
1747 root 20 0 166184 2936 2488 S 0.3 0.3 0:01.14 vmtoolsd
4002 bsc 20   0   29160   1444 884 R  0.3  0.1   0:01.01 top   // R for running 

Press f to select the item listed in Top, press z to list items in color, press W to save the configure of TOP

 

3) ps 

ps is a snapshot of the current process, and top provides dynamic real-time view of a running system. it can display system summary and processes or threads being managed by linux kernel.

bsc@ubuntu:~$ ps aux
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 1 0.1 0.3 33904 3692 ? Ss 07:49 0:01 /sbin/init   //? means it not connected to any tty 
root 2 0.0 0.0 0 0 ? S 07:49 0:00 [kthreadd] // [ ] kernal thread 
root 3 0.0 0.0 0 0 ? S 07:49 0:00 [ksoftirqd/0]
root 5 0.0 0.0 0 0 ? S< 07:49 0:00 [kworker/0:0H]
root 7 0.0 0.0 0 0 ? S 07:49 0:00 [rcu_sched]
root 8 0.0 0.0 0 0 ? S 07:49 0:00 [rcu_bh]
root 9 0.0 0.0 0 0 ? S 07:49 0:00 [rcuos/0]
root 10 0.0 0.0 0 0 ? S 07:49 0:00 [rcuob/0]
root 11 0.0 0.0 0 0 ? S 07:49 0:00 [migration/0]
root 12 0.0 0.0 0 0 ? S 07:49 0:00 [watchdog/0]
root 13 0.0 0.0 0 0 ? S< 07:49 0:00 [khelper]

ps -ef  show the PPID (parpent process ID)

4) change priority 

   two ways, 1) in TOP press r,  and change the nice value, the nice value is -20 to 90 and will be added to priority.

                   2) use command e.g    nice -n 5 dd if=/dev/zero of=/dev/null &   //root user can give negative value, and other user can only give positive value

5) send signal to process 

   two ways 1) kill  -s 9/15 <pid>  // 9 is kill signal, 15 is terminate signal , pid can use e.g  $(pidof dd)

                  2) killall  -s <name of process>

                  2) in Top prss k to kill the proess 

posted @ 2018-05-08 21:16  anyu686  阅读(190)  评论(0编辑  收藏  举报