Home >Operation and Maintenance >CentOS >What should I do if the centos process cannot be killed?

What should I do if the centos process cannot be killed?

WBOY
WBOYOriginal
2022-03-09 10:56:525429browse

方法:1、利用ps命令定位指定进程以及该进程的父进程;2、若使用“Kill -HUP”命令无法杀死指定进程,可杀死指定进程的父进程,语法为“kill -HUP 指定进程父ID”。

What should I do if the centos process cannot be killed?

本文操作环境:centos 7系统、Dell G3电脑。

centos进程杀不死怎么办

发现centos系统发现有两个进程无法杀死,使用了kill PID和kill -9 PID以及kill -15 PID都无法生效

发现这个叫僵尸进程。

解决,如下:

ps -A -o stat,ppid,pid,cmd | grep -e '^[Zz]' | awk '{print $2}' | xargs kill -9

定位僵尸进程以及该僵尸进程的父进程

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

使用Kill -HUP 僵尸进程ID来杀死僵尸进程,往往此种情况无法杀死僵尸进程,此时就需要杀死僵尸进程的父进程

kill -HUP 僵尸进程父ID

然后使用上面的语句查询该僵尸进程是否被杀死

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

参数解读

-A 参数列出所有进程

-o 自定义输出字段 stat(状态)、ppid(进程父id)、pid(进程id)、cmd(命令)

因为状态为z或者Z的进程为僵尸进程,所以我们使用grep抓取stat状态为zZ进程

推荐教程:《centos教程

The above is the detailed content of What should I do if the centos process cannot be killed?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn