如何察看僵尸进程 zombie

来源:互联网 发布:后台远程控制软件 编辑:程序博客网 时间:2024/05/16 16:08

其实这是系统维护每天必看的东西,都非常简单,也就是把平常使用的

ps -ef 多加一个l就可以看到更多详细的信息。


top - 23:59:03 up 45 min,  6 users,  load average: 0.25, 0.88, 0.52

Tasks: 137 total,   1 running, 133 sleeping,   2 stopped,  1 zombie
Cpu(s):  2.7% us,  2.7% sy,  0.0% ni, 92.0% id,  2.7% wa,  0.0% hi,  0.0% si
Mem:    705324k total,   681596k used,    23728k free,     2864k buffers

Swap:  1044184k total,    37512k used,  1006672k free,   430128k cached


[root@Goni 102 ~]# ps -efl
F S UID        PID  PPID  C PRI  NI ADDR SZ WCHAN  STIME TTY          TIME CMD
4 S root         1     0  0  76   0 -   696 -      Mar19 ?        00:00:00 init [5]                             
1 S root         2     1  0 -40   - -     0 migrat Mar19 ?        00:00:00 [migration/0]
1 S root         3     1  0  94  19 -     0 ksofti Mar19 ?        00:00:00 [ksoftirqd/0]
1 S root         4     1  0  65 -10 -     0 worker Mar19 ?        00:00:00 [events/0]
1 S root         5     4  0  68 -10 -     0 worker Mar19 ?        00:00:00 [khelper]
1 S root         6     4  0  75 -10 -     0 worker Mar19 ?        00:00:00 [kacpid]

。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。太多就显示主要的吧

4 S root      6466     1  0  75   0 -  2997 -      Mar19 ?        00:00:00 /usr/bin/gdm-binary -nodaemon
5 S root      7013  6466  0  76   0 -  3148 -      Mar19 ?        00:00:00 /usr/bin/gdm-binary -nodaemon
4 S root      7058  7013  3  75   0 -  9972 -      Mar19 ?        00:01:34 /usr/X11R6/bin/X :0 -audit 0 -auth /var/gdm/:0.Xauth -nolisten tcp vt7
4 S root      7306  7013  0  75   0 -  5310 -      Mar19 ?        00:00:00 /usr/bin/gnome-session
1 Z root      7325  7306  0  75   0 -     0 exit   Mar19 ?        00:00:00 [Xsession] <defunct> 这就是大家需要找的僵尸进程了Z开头的,命令详细介绍如下〉
1 S root      7340  7306  0  76   0 -  1146 -      Mar19 ?        00:00:00 /usr/bin/ssh-agent /bin/sh -c exec -l /bin/bash -c "/usr/bin/dbus-launch --exit-with-session /etc/X11/xinit/Xclients"
1 S root      7373     1  0  75   0 -  1113 -      Mar19 ?        00:00:00 /usr/bin/dbus-launch --exit-with-session /etc/X11/xinit/Xclients
1 S root      7374     1  0  76   0 -  3499 -      Mar19 ?        00:00:00 dbus-daemon-1 --fork --print-pid 8 --print-address 6 --session
0 S root      7379     1  0  75   0 -  3003 -      Mar19 ?        00:00:00 /usr/libexec/gconfd-2 11
1 S root      7382     1  0  79   0 -   877 -      Mar19 ?        00:00:00 /usr/bin/gnome-keyring-daemon


[root@Goni 102 ~]# man ps
PS(1)                                                                                   Linux User鈥檚 Manual                                                                                  PS(1)
NAME
       ps - report a snapshot of the current processes.
。。。。。。。。。。。。。。。。

PROCESS STATE CODES
Here are the different values that the s, stat and state output specifiers (header "STAT" or "S") will display to describe the state of a process.
D    Uninterruptible sleep (usually IO) 这些也看看,,,,,
R    Running or runnable (on run queue)
S    Interruptible sleep (waiting for an event to complete)
T    Stopped, either by a job control signal or because it is being traced.
W    paging (not valid since the 2.6.xx kernel)
X    dead (should never be seen)

Z    Defunct ("zombie") process, terminated but not reaped by its parent.



网上翻译。。。。。。。。

可以用ps 的 – l 选项,得到更详细的进程信息. 
  F(Flag):一系列数字的和,表示进程的当前状态。这些数字的含义为: 
  00:若单独显示,表示此进程已被终止。 
  01:进程是核心进程的一部分,常驻于系统主存。如:    sched、 vhand 、bdflush 等。 
  02:Parent is tracing process. 
  04 :Tracing parent's signal has stopped the process; the parent is waiting ( ptrace(S)). 
  10:进程在优先级低于或等于25时,进入休眠状态,而且不能用信号唤醒,例如在等待一个inode被创建时    
  20:进程被装入主存(primary memory) 
  40:进程被锁在主存,在事务完成前不能被置换   e 
  S(state of? the process ) 
  O:进程正在处理器运行  
  S:休眠状态(sleeping) 
  R:等待运行(runable)    
  I:空闲状态(idle) 
  Z:僵尸状态(zombie)    
  T:跟踪状态(Traced) 
  B:进程正在等待更多的内存页 
  C(cpu usage):cpu利用率的估算值

清除ZOMBIE(僵尸)进程可以使用如下方法: 
  1> kill –18 PPID (PPID是其父进程) 
  这个信号是告诉父进程,该子进程已经死亡了,请收回分配给他的资源。 
  2>如果不行则看能否终止其父进程(如果其父进程不需要的话)。先看其父进程又无其他子进程,如果有,可能需要先kill其他子进程,也就是兄弟进程。方法是: 
  kill –15 PID1 PID2(PID1,PID2是僵尸进程的父进程的其它子进程)。 
  然后再kill父进程:kill –15 PPID 

原创粉丝点击