If you have zombie processes it means those zombies have not been waited for by their parent (look at PPID displayed by ps -l). You have two choices:
- Fix the parent process (make it wait);
- Kill the parent; or live with it.
Remember that living with it is not so hard because zombies take up little more than one extra line in the output of ps.
How to find all Zombie processes
# 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]
or
# ps aux |grep "defunct"
or
# ps aux | awk '{ print $8 " " $2 }' | grep -w Z
How to count all Zombie processes
# ps aux | awk {'print $8'}|grep -c Z
8
# ps aux | awk {'print $8'}|grep Z|wc -l
8
# ps aux | awk '{ print $8 " " $2 }' | grep -wc Z
8
How to kill Zombie processes
kill -9 <PID>