How to kill zombie processes in Ubuntu 18.04 LTS

zombie or nonexistent process on Linux, this is the process that has been completed, but its record still remains in the process table due to the lack of correspondence between the parent and child processes. Typically, the parent process checks the status of its child processes using the wait () function. When the child process is completed, the wait function informs the parent about the complete exit of the process from memory. However, if the parent cannot call the wait function for any of its child processes, the child process remains alive in the system as a dead or zombie process. These zombie processes can accumulate in large quantities in your system and affect its performance. In this case, you may have to kill these zombies manually using the methods and commands described in this guide.

View zombie processes

You can check the performance of your system by looking at the various processes running on your system, including the efficiency that modifies zombie processes. Ubuntu allows you to view these processes as follows:

  • Via graphical user interface
  • Via command line

Via graphical interface

To graphically view any zombie processes running on your system, open System monitor utility through your Ubuntu Dash. In the next screen shot of my system monitor, you can see that two zombies are working on my system. It is also possible that the number of zombie processes on your system may be less or more than those running on mine.

View zombie processes in a graphical interface

Via command line

top The command displays a detailed view of the processes running on your system, as well as the memory and CPU resources that they use. It also gives you information about any zombie processes running on your system. Open a terminal by pressing Ctrl + Alt + T and then enter top, I got the following output after running this command.

$ top

Find zombie processes on the command line

You can see in the second line that 1 zombie process is running on my system.

If you want to get more detailed information about the zombie process, use the following command:

$ ps axo stat,ppid,pid,comm | grep -w defunct

Get detailed information on the zombie process on Linux

This command will give you the state, parentID, process ID, the program that starts the zombie process (a dummy program called “zombie” on my system). The nonexistent flag tells you that this is a dead, zombie process.

Kill the zombie process

First, let’s understand how zombie processes pose a threat to the performance of our system. It is important to find out that zombies are dead and processes that do not take up memory or processor resources are basically completed. However, each of these processes is assigned a unique process identifier obtained from the limited pool of PIDs reserved for your processor. If a large number of zombies is collected, they will gobble up most of the PID pool, and new processes will not be able to start due to the lack of a process identifier.

A small number of non-existent programs occupying your system does not pose a big threat, but this means that their parent programs were not able to recall them due to an error or missing wait () function.

When the parent process cannot call the wait () function automatically, we need to manually instruct the parent process to start the wait function for all its children, so that we can call those that have completed the state. We can do this by running the SIGCHLD command. When this does not work, we can manually kill the parent process so that all its child zombie elements are also destroyed, freeing the process identifiers for new processes.

You can kill zombie processes in the following ways:

  • Via graphical user interface
  • Via command line

Via graphical interface

You can kill a zombie process graphically using the System Monitor Utility as follows:

  1. Open System monitor utility through Ubuntu Dash.
  2. Search by term Zombie through Search button.
  3. Select the zombie process, right-click and then select Murder from the menu.

How to kill a zombie process on a Linux desktop

The zombie process will be killed from your system.

Via command line

After you know that any zombie processes are running on your system using the top command, view the details of these processes.

The usual way is to use the following command, which signals the parent zombie process to kill the command.

$ kill -s SIGCHLD PID

This command may not work in some cases, because not all parent processes are programmed properly to check child processes. In this case, you can kill the parent process with the following command:

$ sudo kill -9 3376

Kill a zombie process on the command line

When you destroy all zombie processes in this way and run the top command, you will see that zombie processes are no longer running on your system:

Zombie process killed

After working with this guide, you can optimize your operating system by looking for any zombie processes in your system and killing them manually through the command line or graphical user interface. This action will free process identifiers for new processes that you want to run on your system.

How to kill zombie processes in Ubuntu 18.04 LTS

Sidebar