page counter next up previous contents
Next: Terminating Processes Up: Managing Processes Previous: Managing Processes   Contents

Monitoring Processes

  1. 程序(process):在系統中觸發任何一個事件時,都會將其定義為一個程序並給一個 ID,即 PID(Process ID)。
  2. 某一程式佔用太多的系統資源,造成系統變得很慢時,能否找出最耗系統的程序,刪除該程序讓系統恢復正常?
  3. ps觀查程序
    [root@deyu ~]# ps
      PID TTY          TIME CMD
     2960 pts/1    00:00:00 su
     3019 pts/1    00:00:00 bash
     6522 pts/1    00:00:00 ps
    
    [root@deyu ~]# ps --help
    ********* simple selection *********  ***
    ....
    a  all w/ tty, including other users ... 
    x  processes w/o controlling ttys    ... 
    -l,l long          u  user-oriented  ...
    ........
    
    [root@deyu ~]# ps aux
    USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
    root         1  0.0  0.0  21336  1436 ?        Ss   06:41   0:00 /sbin/init
    root         2  0.0  0.0      0     0 ?        S    06:41   0:00 [kthreadd]
    root         3  0.0  0.0      0     0 ?        S    06:41   0:00 [migration/0]
    .......
    
  4. top觀察程序
    [root@deyu ~]# top
    
    top - 15:56:47 up  9:15,  9 users,  load average: 0.00, 0.00, 0.00
    Tasks: 210 total,   2 running, 208 sleeping,   0 stopped,   0 zombie
    Cpu(s):  2.0%us,  1.3%sy,  0.0%ni, 96.6%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
    Mem:   3021464k total,  1239316k used,  1782148k free,   101984k buffers
    Swap:   253936k total,        0k used,   253936k free,   458520k cached
    
      PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND                                                         
     2664 dywang    20   0  309m  18m  12m S  3.2  0.6   0:16.62 gnome-terminal                                                  
     2419 root      20   0  175m  33m  12m S  2.9  1.1   3:30.19 Xorg                                                            
     3191 dywang    20   0  938m 196m  38m S  0.5  6.6   9:58.24 firefox
    
    ## h key provides more information
    ## M key orders processes by memory use
    ## P key orders processes by CPU use
    ## q key quit top
    



2015-04-13