Today we will learn about zombie processes. In particular, we will guide you to find and kill zombie processes on your Linux / Unix operating systems.
What is a zombie process?
On Linux / Unix operating systems, a defunc process (aka zombie process) is a system process that has completed its execution, however it still show on the system process table. In other words, it’s an empty process, that is not executing any task, but still exist and has a process ID.
If there is a zombie process, there is a parent process around. And the same as in the movies, zombies do not react to normal ways of killing. On Unix / Linux it’s the same, you can’t kill the zombie, but you can kill the parent process, which will make the zombie process dissapear immediately.
Zombie processes can be found on almost any Unix / Linux operating system, and that also includes cPanel servers.
How can I list zombie processes on my system?
Example: finding zombie processes using ps and grep.
ps aux |grep "defunct"
ps aux | grep 'Z'
[firstname.lastname@example.org:~]ps aux | grep 'Z' USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND root 28115 0.0 0.0 103320 864 pts/0 S+ 09:26 0:00 grep Z johndoe 3572 0.0 0.0 0 0 ?? Z 20:41 0:00 some.command
Kill zombie processes
Now in order to kill the zombie process, just kill the 3572 process and it should be gone. Let’s use pstree command to fund out the parent process
pstree -p -s 3572
The output should be something like:
This will show the pid of the of the parent of the zombie process. Now you need to kill the parent process.
[root@server]# kill -9 3572
All done, now you know how to find and kill zombie processes on Linux / Unix operating systems. Do you know other ways to find and kill zombie processes on Linux / Unix? Please share your knowledge with us.