9

面试官:kill -9 进程杀不掉,怎么办?

 3 years ago
source link: http://mp.weixin.qq.com/s?__biz=MzU2NjIzNDk5NQ%3D%3D&%3Bmid=2247489680&%3Bidx=1&%3Bsn=81f8b227f531ccb98a28ca868d7cebf1
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

点击上方 匠心零度 ,选择“ 设为星标

做积极的人,而不是积极废人

my6vaen.jpg!web

来源 | https://blog.csdn.net/21aspnet/article/details/6754445

用ps和grep命令寻找僵尸进程

ps -A -ostat,ppid,pid,cmd | grep -e '^[Zz]'

命令注解: -A 参数列出所有进程 -o 自定义输出字段 我们设定显示字段为 stat(状态), ppid(进程父id), pid(进程id),cmd(命令)这四个参数 因为状态为 z或者Z的进程为僵尸进程,所以我们使用grep抓取stat状态为zZ进程 运行结果参考如下

Z 12334 12339 /path/cmd

这时,我们可以使用 kill -HUP 12339来杀掉这个僵尸进程

运行后,可以再次运行

ps -A -ostat,ppid,pid,cmd | grep -e '^[Zz]'

来确认是否已经将僵尸进程杀死 如果kill 子进程的无效,可以尝试kill 其父进程来解决问题,例如上面例子父进程pid是 12334,那么我们就运行

kill -HUP 12334

来解决问题

一般可以用top命令发现动态进程表

EZfa6fN.jpg!web

其中zombie是僵尸进程

END

如果读完觉得有收获的话,欢迎点【好看】,关注【匠心零度】,查阅更多精彩历史!!!

nmqYriz.gif

让我“ 好看 ”  bYreamJ.gif


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK