Operations 3 min read

How to Detect and Kill Zombie Processes with ps and grep

This guide shows how to use the ps command combined with grep to list zombie processes, explains each option, demonstrates killing the identified zombies with kill -HUP, and provides tips for verifying removal and using top to monitor processes.

Programmer DD
Programmer DD
Programmer DD
How to Detect and Kill Zombie Processes with ps and grep

Using ps and grep to Find Zombie Processes

Run the following command to list all processes and filter those whose state is Z (zombie): ps -A -ostat,ppid,pid,cmd | grep -e '^[Zz]' Explanation of options: -A: list all processes. -o: customize output fields; we display stat (state), ppid (parent PID), pid (process ID), and cmd (command). Zombie processes have a state of Z or z.

Sample output might look like: Z 12334 12339 /path/cmd To terminate the zombie, send a hang‑up signal to its PID: kill -HUP 12339 Re‑run the ps command to confirm the zombie is gone. If the child process cannot be killed, try terminating its parent process (PID 12334 in the example): kill -HUP 12334 Alternatively, you can use top to view a dynamic process table and identify zombies visually.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

process managementGrepps commandzombie process
Programmer DD
Written by

Programmer DD

A tinkering programmer and author of "Spring Cloud Microservices in Action"

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.