How to Locate and Eliminate Zombie Processes with ps, grep, and kill
This guide explains how to use the ps and grep commands to identify zombie processes on Linux, shows the command syntax, interprets the output, and provides step‑by‑step instructions for terminating the zombie and its parent process if needed.
Zombie processes are defunct entries that remain in the process table after their child has terminated but the parent has not yet read the exit status. They can be identified by a status code of Z or z.
Finding Zombie Processes
Run the following command to list all processes and filter for zombies: ps -A -ostat,ppid,pid,cmd | grep -e '^[Zz]' Explanation of options: -A: list all processes -o: customize output fields; here we request stat (status), ppid (parent PID), pid (process ID), and cmd (command) grep -e '^[Zz]': select lines where the status field starts with Z or z, indicating a zombie
Typical output looks like:
Z 12334 12339 /path/cmdTerminating the Zombie Process
First try to kill the zombie directly using its PID (the third column): kill -HUP 12339 After executing, run the detection command again to verify the zombie is gone.
If the zombie persists, kill its parent process (the second column) instead: kill -HUP 12334 This forces the parent to reap the zombie.
Alternative View with top
The top command also shows a dynamic process table where zombie entries are labeled as zombie.
By following these steps you can reliably locate and clean up zombie processes on a Linux system.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Liangxu Linux
Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
