On Linux servers, there will be some zombie processes. Here is how to quickly find and eliminate these zombie processes
First, we can use the top command to check whether there are currently zombie processes on the server. You can see the zombie processes in the picture below Number tips, if the number is greater than 0, it means that there are currently zombie processes on the server
Below, we use the ps and grep commands to find zombie processes
ps -A -ostat,ppid,pid,cmd | grep - e '^[Zz]'
Command notes:
-A parameter lists all processes
-o Custom output fields We set the display fields to stat (status), ppid (process parent id), pid( The four parameters of process id) and cmd (command)
Because the process with status z or Z is a zombie process, we use grep to grab the stat status zZ process
The running results are as follows
Z 12334 12339 /path /cmd
At this time, we can use kill -HUP 12339 to kill this zombie process
After running, you can run ps -A -ostat,ppid,pid,cmd | grep -e '^[Zz]' To confirm whether the zombie process is killed
If killing the child process is invalid, you can try to kill its parent process to solve the problem. For example, in the above example, the parent process pid is 12334, then we run
kill -HUP 12334
For more articles related to finding and killing zombie processes in Linux systems, please pay attention to the PHP Chinese website!