How to Find and Kill All Zombie Processes

Thanks to ServerNooBs

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.

[root@server]# kill -9
Advertisements

Hi All, I like to spend time on black and white screen with linux. I love to learn new things in linux specially in virtualization. Currently I am working on OpenStack like to dig deep.

Posted in Linux

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: