linux 下处理僵尸进程

本文介绍如何使用top命令检查僵尸进程,并通过ps与grep命令组合找到具体僵尸进程PID,最后给出批量杀除僵尸进程的方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

   在我们经常接触运维的过程中,经常会遇到僵尸进程的问题,有些会自动回收掉,有些则不能,如果数理过多,会对服务器产生大的影响

如何查到僵尸进程

top cmd


top - 09:41:16 up 157 days, 19:44,  8 users,  load average: 19.28, 26.37, 37.92
Tasks: 781 total,  17 running, 758 sleeping,   0 stopped,   6 zombie
Cpu(s): 49.3%us, 14.6%sy,  0.0%ni, 35.6%id,  0.3%wa,  0.0%hi,  0.2%si,  0.0%st
Mem:     48270M total,    36361M used,    11909M free,     2084M buffers
Swap:    32773M total,        0M used,    32773M free,    24173M cached
 Not valid

存在6个僵尸进程

找到僵尸进程

linux-wawp:~ # ps -ef |grep defunc
mos5200   3675  3663  0 Oct08 ?        00:00:00 [sh] <defunct>
mos5200   3862  3852  0 Oct08 ?        00:00:00 [sh] <defunct>
mos5200   3902  3822  0 Oct08 ?        00:00:00 [sh] <defunct>
mos5200   3917  3899  0 Oct08 ?        00:00:00 [sh] <defunct>
mos5200  29217 29212  0 Oct15 ?        00:00:00 [sh] <defunct>
mos5200  32099 27819  0 09:43 pts/4    00:00:00 [sort] <defunct>
mos5200  32100 27819  0 09:43 pts/4    00:00:00 [head] <defunct>
root     32159 24787  0 09:43 pts/6    00:00:00 grep defunc
mos5200  32459 32432  0 Oct04 ?        00:00:00 [sh] <defunct>

杀死僵尸进程

su -  到root用户下

kill -9  3675  3663  杀死一个僵尸进程

如果有很多的话

ps -ef|grep defunct | grep -v grep |awk '{print "kill -9 " $2,$3}'|sh

 

 

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值