Process management is a daily task for Linux sysadmins. Zombie processes, runaway CPU consumers, and memory-hogging applications can degrade server performance and eventually cause outages. This guide covers practical techniques for identifying and managing problematic processes on Linux servers.
Understanding Process States
Linux processes exist in several states visible in the STAT column of ps:
- R β Running or runnable
- S β Sleeping (waiting for event)
- D β Uninterruptible sleep (usually I/O)
- Z β Zombie (terminated but not reaped by parent)
- T β Stopped (by signal or debugger)
Finding Zombie Processes
Zombies are dead processes whose parent has not called wait() to collect their exit status:
# Find zombies
ps aux | awk '$8 ~ /Z/'
# Find zombie parent PID
ps -eo pid,ppid,stat,comm | grep Z
# Count zombies
ps aux | grep -c " Z"
You cannot kill a zombie directly β you must kill or fix its parent process. If the parent is PID 1 (init/systemd), a reboot may be needed.
Finding Resource Hogs
# Top 10 CPU consumers
ps aux --sort=-%cpu | head -10
# Top 10 memory consumers
ps aux --sort=-%mem | head -10
# Processes using more than 1GB RSS
ps aux | awk '$6 > 1048576 {print $0}'
# Long-running processes (sorted by elapsed time)
ps -eo pid,etimes,user,comm --sort=-etimes | head -20
Automated Process Analysis
pip install dargslan-process-killer
dargslan-prockill report # Full process analysis
dargslan-prockill zombies # Find zombie processes
dargslan-prockill hogs # Resource hog finder
dargslan-prockill topcpu # Top CPU consumers
dargslan-prockill topmem # Top memory consumers
dargslan-prockill long # Processes running > 24h
Process Control Commands
kill PID # Graceful termination (SIGTERM)
kill -9 PID # Force kill (SIGKILL)
kill -HUP PID # Reload configuration (SIGHUP)
pkill -u username # Kill all processes by user
killall nginx # Kill all processes by name
nice -n 10 command # Start with lower priority
renice -n 5 -p PID # Change running process priority
Best Practices
- Monitor zombie count in your alerting system
- Set process resource limits with ulimit and cgroups
- Use systemd resource controls (MemoryMax, CPUQuota) for services
- Investigate D-state processes β they indicate I/O problems
- Track long-running processes that should have completed
- Never use kill -9 as first resort β try SIGTERM first
Download our free Process Management & Cleanup Cheat Sheet for essential process commands. For deeper Linux knowledge, explore our Linux & DevOps eBooks.