[interview question] kill – 9 process can’t be killed. What should I do?

Time:2021-2-24

[interview question] kill - 9 process can't be killed. What should I do?

Author: 21aspnet
Link: https://blog.csdn.net/21aspne…

Using PS and grep commands to find zombies

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

Command comment:

  • -The a parameter lists all processes
  • -O custom output field we set the display fields as stat (state), PPID (process parent ID), PID (process ID) and CMD (command), because the process with Z or Z status is a zombie process.

So we use grep to grab the process whose stat state is ZZ. The running results are as follows:

Z 12334 12339 /path/cmd

At this time, we can use kill – HUP 12339 to kill the zombie process

After running, you can run it again

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

To confirm whether the zombie process has been killed. If the killing of the child process is invalid, you can try to kill the parent process to solve the problem. For example, in the above example, if the parent process PID is 12334, then we will run

kill -HUP 12334

To solve the problem

Generally, you can use the top command to find the dynamic process table

[interview question] kill - 9 process can't be killed. What should I do?

Zombie is a zombie process

If there are errors or other problems, welcome to comment and correct. If you have any help, please click like + forward to share.

Welcome to the official account of the brother of migrant workers:The way of migrant workers’ Technology
[interview question] kill - 9 process can't be killed. What should I do?