Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

how do I detect and kill zombie processes left from the command line of a Linux terminal?

share|improve this question

migrated from Apr 28 '11 at 16:00

This question came from our site for professional and enthusiast programmers.

You can't kill the undead :P. Zombie process are dead process that are waiting to be "waited" with the parent process. In this process the parent knows how their children ended. When ever the terminal ends, this process will be inherit by init and init will "wait" them. So what you need is to kill/end the parent process. – anizzomc Apr 28 '11 at 15:17

You cannot kill a zombie process. If the parent process does not call wait(), you have to kill the parent process to remove the zombie.

share|improve this answer

You can grep for "defunct", or check for Z in the "state" output

ps -eo state,pid,cmd | grep "^Z"

If you want to kill it as well

ps -eo state,ppid | awk '$1=="Z"{cmd="kill -9 "$2;system(cmd) }'
share|improve this answer


ps aux

and look at the status column. Zombie are represented by letter Z.

share|improve this answer

try ps ax -o state -o ppid | awk '$1=="Z"{print $2}' | xargs kills all zombies

share|improve this answer
Can you expand your answer a little to explain what the code does? (I'm envisioning that maybe the ax is used to cut off their heads? :-) ) – fixer1234 Mar 30 at 15:28
While this command may answer the question, providing additional context regarding why and/or how it answers the question would significantly improve its long-term value. Please edit your answer to add some explanation. – Toby Speight Mar 30 at 15:52

You must log in to answer this question.