Linux - How to kill zombie process, What is a zombie process

How to kill zombie process

As a Linux admin you might have many questions regarding zombie process, What is a zombie process? How to kill a zombie process? How can I find the Process ID's(PID) of a zombie process and many more. Here you can find few answers for you all questions together.

Zombies are dead processes. zombie process cannot be killed, because you can not kill the process which is already dead. All processes eventually die, and when they do they become zombies. They consume almost no resources, which is to be expected because they are dead! The reason for zombies is so the zombie's parent (process) can retrieve the zombie's exit status and resource usage statistics. The parent signals the operating system that it no longer needs the zombie by using one of the wait() system calls. The zombie process consumes no CPU resource. The reason for zombies is so the zombie's parent (process) can retrieve the zombie's exit status and resource usage statistics. The parent signals the operating system that it no longer needs the zombie by using one of the wait() system calls.

When a process dies, its child processes all become children of process number 1, which is the init process. If you have zombie processes it means those zombies have not been waited for by their parent, You can find the parent Process ID from PPID. To find the PPID, please use the below command.
# ps -l

F S   UID   PID  PPID  C PRI  NI ADDR SZ WCHAN  TTY          TIME CMD
4 S     0  2930  2915  0  80   0 -  1872 wait   pts/0    00:00:00 su
4 S     0  2936  2930  0  80   0 -  1347 wait   pts/0    00:00:00 bash
4 R     0  2981  2936  0  80   0 -  1175 -      pts/0    00:00:00 ps

We have three options to handle the zombie process
1) Fix parent process (make it wait)
2) Kill the parent
3) Let the zombie process be as it is, because it does not consume any CPU resource.

How do I find Zombie Process?
 # top

 # ps aux | awk '{ print $8 " " $2 }' | grep -w Z

OUTPUT:
Z 2544
Z 2785

How to kill a zombie process?
You cannot kill zombies
, as they are already dead. But if you have too many zombies then kill parent process or restart service. You can kill zombie process using PID obtained from any one of the above command. Anyhow, this does not Guarantee to kill the zombie process.
 
 # kill -9 2544

The topic on Linux - How to kill zombie process is posted by - Guru

Hope you have enjoyed, Linux - How to kill zombie processThanks for your time

Tech Bluff