How to Identify and Eliminate Zombie Processes on Linux – Guide

Let me remind you of what is a process in Linux before you learn about the Zombie process. In a nutshell, a process is a running instance of a program that is now in use. It could be cutting edge (interactive process) or background (batch process) (non-interactive or automatic process). It can be a parent process (one that creates additional processes during runtime) or a child process (one that is produced by others). Except for the first init (or systemd) process, which has PID 0, all other processes on Linux have a parent. Child processes are also created by processes. The problem can arise if your system has limited RAM or if there are too many zombie processes eating up RAM. Also, most Linux processes can have the maximum PID set to 32768. If there are no IDs available for other productive tasks, your system might crash. This rarely happens, but it is a possibility, especially if a poorly coded program starts inducing multiple zombie processes. In that case, it would be a good idea to find and kill the zombie process.

How to find zombie processes

A process on Linux can have one of the following states: But where can you see the processes and their respective status? An easy way is to use the terminal and the top command. Now, the question arises, how to kill the zombie process?

How to find and kill a zombie process

A zombie process is already dead. How do you kill an already dead process? In zombie movies, you shoot zombies in the head or burn them. That’s not an option here. You can burn your system to kill the zombie process, but this is not a viable solution 😉 Some people suggest sending SIGCHLD signal to the parent process. But it is more likely to be ignored. The other option to kill the zombie process is to kill its parent process. This sounds brutal, but this is the only safe way to kill zombie processes. So first let’s list the zombie processes to know their ID. This can be achieved using ps command like this in terminal. ps ux | awk ‘{if($8==”Z+”) print}’ The 8th column in the ps ux command output displays the state of a process. You are asking to print all matching lines where the state of a process is Z+ (indicating the zombie state). After identifying the process ID, let’s get the parent process ID. ps -o ppid= -p Alternatively, you can combine the above two commands as follows, where it directly provides the PID of the zombie process and the PID of its parent process. ps -A -ostat,pid,ppid | grep -e’[zZ]’ Here you get the ID of the parent process, so finally kill the process by typing the command line with its respective process ID obtained before.

Final note

I hope you like the guide How to Identify and Eliminate Zombie Processes on Linux. In case if you have any query regards this article you may ask us. Also, please share your love by sharing this article with your friends.