Kill all Zombie processes (Guaranteed!)

kill -9 `ps -xaw -o state -o ppid | grep Z | grep -v PID | awk '{print $2}'`
It identifies the parents of the Zombie processes and kill them. So the new parent of orphan Zombies will be the Init process and he is already waiting for reaping them. Be careful! It may also kill your useful processes just because they are not taking care and waiting for their children (bad parents!).
Sample Output
No output. But if you want to see the PIDs of your Zombies' parents just use this piece:
ps -xaw -o state -o ppid | grep Z | grep -v PID | awk '{print $2}

2010-10-27 07:29:14

4 Alternatives + Submit Alt

What Others Think

nice.. great idea
AskApache · 609 weeks and 4 days ago
the ppid version is a bit too dangerous for me though..
AskApache · 609 weeks and 4 days ago
@AskApache: Try it once. You will see it is not so dangerous. It even killed one of SSHD daemons in my remote server but I'm still connected to it without any problem!
khashmeshab · 609 weeks and 4 days ago
Didnt work got this error not sure what it means
Bonster · 609 weeks and 3 days ago
@Bonster: What OS do you use? (uname -a)
khashmeshab · 609 weeks and 3 days ago
On Ubuntu 11.10, I had to omit the 1st ' - ' : kill -9 `ps -xaw -o state -o ppid | grep Z | grep -v PID | awk '{print $2}'` Warning: bad syntax, perhaps a bogus '-'? See /usr/share/doc/procps-3.2.7/FAQ this works: kill -9 `ps xaw -o state -o ppid | grep Z | grep -v PID | awk '{print $2}'`
cyba84 · 548 weeks and 4 days ago
I don't think mindlessly killing parent processes just to get rid of zombies is the way to go. This one-liner is certainly correct (as opposed to the original submission) but the big picture of this problem is still way off.
wejn · 494 weeks and 1 day ago ??? ? ????? ????
seofox · 21 weeks and 3 days ago
seofox · 20 weeks and 4 days ago

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this? is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands

Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.


Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: