My process list shows <defunct> zombie entries. How do I clean them up?

Quick Linux Tip #29:

Try: ps -eo pid,ppid,stat,cmd | awk '$3 ~ /Z/'

Info: Zombies have STAT=Z and are already-dead processes waiting for their parent to reap them. You cannot kill a zombie directly. Send SIGCHLD to its parent process (PPID) to prompt it to reap the child.

Examples:

  • $ ps aux | grep defunct  # Quick search for zombies
  • $ kill -SIGCHLD <PPID>  # Prompt parent to reap children
  • $ kill -9 <PPID>  # Last resort if parent is unresponsive

Note: Zombies consume almost no CPU or memory, but they continue to occupy process-table/PID entries. If SIGCHLD does not clear them, the parent may not be handling child termination correctly. Restarting or terminating the parent can cause the zombies to be reparented and subsequently reaped, but identify the parent carefully before using kill -9.




LinuxTeck.com
linuxteck@ubuntu:~$ ps -eo pid,ppid,stat,cmd | awk '$3 ~ /Z/'
  PID  PPID STAT CMD
 3456  1234    Z [python] <defunct>
 4567  1234    Z [worker] <defunct>
 5678  1234    Z [child] <defunct>

linuxteck@ubuntu:~$ kill -SIGCHLD 1234

linuxteck@ubuntu:~$ ps -eo pid,ppid,stat,cmd | awk '$3 ~ /Z/'
linuxteck@ubuntu:~$

PREVIOUS ARTICLE Quick Linux Tip #28: How do I compress old logs but still grep them without decompressing? NEXT ARTICLE Quick Linux Tip #30: How do I tail a log file with colored output for errors?
About John Britto

John Britto Founder & Chief-Editor @LinuxTeck. A Computer Geek and Linux Intellectual having more than 20+ years of experience in Linux and Open Source technologies.

View all posts by John Britto →

Leave a Reply

Your email address will not be published.