In Linux, a zombie process is a terminated process that remains in the process table because its parent process has not yet read its exit status.
It occurs when a child process completes but its parent process hasn’t called wait()
to retrieve the child’s status.
These “defunct” processes consume minimal resources but can clutter the process table if left uncleared.
Here’s a quick guide to check for and handle them effectively.
-
Check for Zombie Processes
Use thetop
command to see the system’s process summary. Look for “zombie” in the Tasks section to see the count of zombie processes.top # Example output: # Tasks: 717 total, 2 running, 714 sleeping, 0 stopped, 1 zombie
-
Identify Zombie Processes
Useps
with the-A
option to list all processes and search for defunct (zombie) entries.ps -A -ostat,pid,ppid | grep -e '[zZ]' # Example output: # Zs 3379981 2279581
-
Trace the Parent Process
Check the parent process (PID 2279581) causing the zombie by using:ps -ef | grep 2279581
-
Terminate the Parent Process
Killing the parent process often removes zombie processes:kill -9 2279581
-
Verify Zombies are Cleared
Runtop
orps
again to confirm the zombie count is zero.top # Expected output: # Tasks: 712 total, 1 running, 711 sleeping, 0 stopped, 0 zombie
Following these steps helps maintain a clean and optimized Linux environment by removing leftover zombie processes effectively.
See our documentation here