Ridding your Solaris host of zombie processes

We encountered a nasty bug in our backup software this week. When this bug is triggered, each job (one process is created per job) that completes will turn into a zombie. After a few days we will have hundreds or even thousands of zombie processes, which if left unchecked will eventually lead to the system-side process table filling up. Solaris comes with a nifty tool to help deal with zombies (no, they don’t ship you a shotgun with your media kit), and it comes by the name preap. To use preap, you can pass it the PID of the zombie process you want to reap:

$ ps -ef | grep defunct

    root   646   426   0        - ?           0:00 <defunct>
    root  1489 12335   0 09:32:54 pts/1       0:00 grep defunct

$ preap 646
646: exited with status 0

This will cause the process to exit, and the kernel can then free up the resources that were allocated by that process. On a related note, if you haven’t seen the movie zombieland you are missing out!!!! That movie is hilarious!

4 Comments

sgk  on June 30th, 2010

Just a thought, but what caused that first line to be a match for “grep defunct” if it didn’t actually include the word defunct in it ?

Felipe Alfaro Solana  on June 30th, 2010

How does “preap” actually work?

matty  on June 30th, 2010

@sgk — it looks like there was a formatting bug (greater than and less than signs need to be escaped). I fixed the post.
@Felipe — you can see how it works here.

Dustin J. Mitchell  on July 3rd, 2010

What backup software? Amanda has this problem, but shouldn’t create too many of them, and they should die quickly.

Leave a Comment