How to Find and Kill All Zombie Processes

On Unix operating servers, a zombie process or defunct process is a process that has completed execution but still has an entry in the process table, allowing the process that started it to read its exit status.

How to Find and Kill All Zombie Processes

It almost always means that the parent is still around. If the parent exited, the child would be orphaned and re-parented to init, which would immediately perform the wait(). In other words, they should go away once the parent process is done.
A zombie process doesn’t react to signals.

1. How can I get the Zombie from process list…?
Its very simple. You can find out Zombie process with the following way:

# ps aux |grep "defunct"

user1      3366  0.0  0.0      0     0 ?        Z    07:34   0:00 [chromium-browse]
user1      3435  0.0  0.0      0     0 ?        Z    07:44   0:19 [chromium-browse]
user1      3722  0.0  0.0      0     0 ?        Z    08:21   0:00 [pidgin] defunct
user1      4287  0.1  0.0      0     0 ?        Z    09:26   0:38 [chromium-browse]
user1      5378  0.1  0.0      0     0 ?        Z    11:24   0:15 [chromium-browse] defunct
# ps aux |grep Z

USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
user1      3366  0.0  0.0      0     0 ?        Z    07:34   0:00 [chromium-browse] 
user1      3435  0.0  0.0      0     0 ?        Z    07:44   0:19 [chromium-browse] 
user1      3722  0.0  0.0      0     0 ?        Z    08:21   0:00 [pidgin] 
user1      4287  0.1  0.0      0     0 ?        Z    09:26   0:38 [chromium-browse] 
user1      5378  0.1  0.0      0     0 ?        Z    11:24   0:15 [chromium-browse]

2. How many Zombie process running on your server?

# ps aux | awk {'print $8'}|grep -c Z
5
# ps aux | awk '{ print $8 " " $2 }' | grep -wc Z
5
# ps aux | awk {'print $8'}|grep Z|wc -l
5

3. List the PID of Zombie ?

# ps aux | awk '{ print $8 " " $2 }' | grep -w Z
Z 3366
Z 3435
Z 3722
Z 4287
Z 5378

In order to kill these processes, you need to find the parent process first.

# pstree -paul

This will show the pid of the of the parent of the zombie process. Now you need to kill the parent process.

[[email protected]]# kill -9

Hope this article helps you. Please share you valuable comments to improve us.

For changing the SSH port number : Click Here