May 22, 2009

Checking for and Killing Zombie Processes

Zombie processes are processes that are no longer in use by their parent, yet the parent hasn't properly killed the process yet.   Zombie processes aren't necessarily bad, but a high number of them can be. Don't feel that you must automatically kill all zombie processes because they'll just come back. Just kill them after many (maybe > 50) have accumulated.

 These should work with pretty much any OS.  I've tested these in Ubuntu and CentOS

Checking for Zombies

ps -A -ostat,ppid,pid,cmd | grep -e '^[Zz]'

Automatically kill all zombie processes

sudo kill -HUP `ps -A -ostat,ppid,pid,cmd | grep -e '^[Zz]' | awk '{print $2}'`
Click Here!