Home » Server Managment » How to Find and Kill All Zombie Processes

How to Find and Kill All Zombie Processes

On Unix operating systems, 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. 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"

arun      3366  0.0  0.0      0     0 ?        Z    07:34   0:00 [chromium-browse] defunct
arun      3435  0.0  0.0      0     0 ?        Z    07:44   0:19 [chromium-browse] defunct
arun      3722  0.0  0.0      0     0 ?        Z    08:21   0:00 [pidgin] defunct
arun      4287  0.1  0.0      0     0 ?        Z    09:26   0:38 [chromium-browse] defunct
arun      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
arun      3366  0.0  0.0      0     0 ?        Z    07:34   0:00 [chromium-browse] 
arun      3435  0.0  0.0      0     0 ?        Z    07:44   0:19 [chromium-browse] 
arun      3722  0.0  0.0      0     0 ?        Z    08:21   0:00 [pidgin] 
arun      4287  0.1  0.0      0     0 ?        Z    09:26   0:38 [chromium-browse] 
arun      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

Originally posted 2016-02-08 20:28:10.

About admin

I have been working with Linux based systems since 2002. I hope the article published on this site will be useful to those new to server administration.