What are zombie processes in Linux and how to manage them

Zombie processes don’t pose a threat to your NVMe VPS Server in terms of resource usage. That’s because the process has already been run and completed. They do pose a threat in terms of PIDs. Processes are assigned a PID number when they run and a server has a limited number of PIDs to assign to processes. If lots of defunct processes gather they will be using lots of PID numbers and eventually if not resolved there will be no more PIDs to assign to new processes. Zombie processes are processes the server has completed but not terminated. You might see;


When looking at the processes using top or htop in the server these are Zombie processes.

Indications of Zombie Processes

Some servers display large CPU usage, and some servers like Virtuozzo Servers might become unresponsive and unmanageable. We call these Zombie servers. The best way to tell if you have a Zombie server is by using htop. This screen details if you have any zombie processes on the top right.

Here was can see over 3285 processes have gathered together all using PIDs. If left this server will start to see issues. It’s also displaying a high load but the actual CPU usage is low, There is plenty of memory but the wait time is high. The obvious answer to this is the defunct processes.

Terminating Zombie Processes

Sometimes you can terminate these processes but it doesn’t always work. The kill script can be used to attempt to terminate one of the defunct processes to see if it will work. Looking at the processes in the server choose a PID. We are using 51678

51678 ? 00:00:00 crond <defunct>
51681 ? 00:00:00 run-parts <defunct>
51687 ? 00:00:00 logrotate <defunct>
51688 ? 00:00:00 awk <defunct>
51689 ? 00:00:00 logrotate <defunct>
51690 ? 00:00:00 sh <defunct>
51691 ? 00:00:00 service <defunct>
51698 ? 00:00:00 named <defunct>

Kill the process

Use the kill -9 PID script to attempt to kill the process

kill -9 51678

If after using the kill script you can still see the PID then the only viable option is to reboot the server.

Zombies Processes on Virtuozzo hosts

Defunct processes can turn a server into a zombie server. These are servers that become unresponsive. You are not able to shut down the server due to the open processes and you also can’t terminate the processes. Again the only viable option to resolve this on a Virtuozzo host is to reboot the whole host.

Inspect processes inside a Virtuozzo server

If you are using VPS Server you can inspect processes inside a container by using vzps -E CTID. You can grab the CTID of a container by using vzlist -a

4142   51689 ?  00:00:00 logrotate <defunct>
4142   51690 ?  00:00:00 sh <defunct>
4142   51691 ?  00:00:00 service <defunct>
4142   51698 ?  00:00:00 named <defunct>
4142   51709 ?  00:00:00 rndc <defunct>

Related Articles

Leave a Reply

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

Back to top button