Zombie Apocalypse on Your Linux Server

Zombie processes. Let’s start off by asking the question:

What Is A Zombie Process?

The short answer to What Is A Zombie Process is as follows: A zombie process is a process that refuses to die. Why won’t it die? Because essentially the process is already dead. So we’re left with zombie processes that you may not be able to kill even with a kill -9.

zombie processes

How to Find Zombie Processes

My favorite way to find zombie processes is by using good old ‘ps‘ and ‘grep‘. We want to find processes that are flagged with ‘Z’ so you can try something like the following. Make sure to include spaces between the quotes like so:

ps -aux | grep " Z "

Running the preceding command should output something like this, with the process ids with status “Z” returned. This is super helpful since it allows to drill down and shed some light on the issue. In our case, we found that the zombie processes on our server were actually some defunct ssh related processes:
[admin@linux1] {~} ps -aux | grep " Z "
admin 12448 0.0 0.0 114888 1004 pts/1 S+ 04:30 0:00 grep --color=auto Z
root 15559 0.0 0.0 0 0 ? Z Nov04 0:00 [ssh]
root 15763 0.0 0.0 0 0 ? Z Nov04 0:00 [ssh]
root 15824 0.0 0.0 0 0 ? Z Nov04 0:00 [ssh]
root 15876 0.0 0.0 0 0 ? Z Nov04 0:00 [ssh]

How to Kill Zombie Processes

The good news is that now that you’ve used ps to returned the process ids related to the zombie processes, you can simply kill them, right? Well, probably not. In my experience, most of the time you cannot kill a zombie process because…it’s already dead (we said that in the intro). You are free to go ahead and try executing a sudo kill -9 PID but this will likely not work. If it does work, bonus!

So you have two options:

a) Live with the undead of all processes. If there are not too many and they are not affecting server/workstation performance, let them be.
b) Shutdown/reboot. Yes, this is the last resort and the most embarrassing option. Indeed Linux folks don’t like to reboot a server for any reason, but sometimes this is the only and cleanest way to clear those pesky zombie processes. I would recommend a full shutdown + reboot over just a reboot, just make sure that you have access to the RAC/iLO or VM to bring the machine back up. Enjoy!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.