Kill zombie processes in Linux
Check zombie processes with the top command
Check Linux distrubtion
Linux command and output
Check amount of zombie processes with the top command (see second line below)
top - 09:38:14 up 387 days, 18:32, 1 user, load average: 2.12, 2.38, 2.57
Tasks: 717 total, 2 running, 714 sleeping, 0 stopped, 1 zombie
%Cpu(s): 19.6 us, 1.2 sy, 0.0 ni, 79.2 id, 0.1 wa, 0.0 hi, 0.0 si, 0.0 st
########################################################
Find the zombie processes
root@hetz-root ~ $ ps -A -ostat,pid,ppid | grep -e '[zZ]'
Zs 3379981 2279581
root@hetz-root ~ $ ps -ef | grep 2279581
5050 2279581 2279435 0 Mar19 ? 00:46:55 /venv/bin/python3 /venv/bin/gunicorn --limit-request-line 8190 --timeout 86400 --bind [::]:80 -w 1 --threads 25 --access-logfile - -c gunicorn_config.py run_pgadmin:app
5050 3379981 2279581 0 Sep02 ? 00:00:00 [python3] <defunct>
---------------------------
root@hetz-root ~ $ ps -ef | grep 3379981 | grep -v grep
5050 3379981 2279581 0 Sep02 ? 00:00:00 [python3] <defunct>
########################################################
Kill the zombie process
root@hetz-root ~ $ kill -9 2279581
root@hetz-root ~ $ ps -ef | grep 3379981 | grep -v grep
root@hetz-root ~ $ ps -A -ostat,pid,ppid | grep -e '[zZ]'
########################################################
Check for zombie processes again
top - 09:47:10 up 387 days, 18:41, 1 user, load average: 2.64, 2.50, 2.52
Tasks: 712 total, 1 running, 711 sleeping, 0 stopped, 0 zombie
%Cpu(s): 10.8 us, 1.9 sy, 0.0 ni, 87.3 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
Links:
https://www.linuxjournal.com/content/how-kill-zombie-processes-linux
https://www.baeldung.com/linux/clean-zombie-process