Zombie trial. Not everyone has heard of this interesting but scary word referring to the Linux operating system. On a PC, zombie processes may not pose a threat to a normal user. However, on Linux servers, these processes must be identified and stopped.
Such processes can cause problems with your system's process table and in turn affect the proper functioning of your machine. Hence, in this article, we are going to cover zombie processes in depth, as well as a comprehensive guide on how to find and kill zombie processes on a Linux computer.
What are zombie trials?
Most of all, it is important that you know what zombie processes really are. These are nothing more than dead and broken processes that are taking up space in the system process table. A process control block or circuit board is a data structure that stores details about individual processes running on your system.
The process table consists of the process ID, a link to the circuit board, and other useful information about the process. Zombie processes have their own process IDs and memory management information. Since there are only a limited number of process IDs available for the Linux operating system, other processes cannot use the PIDs until the zombie process has stopped.
Although one or two zombie processes will not cause glitches or performance problems on your computer, a large number of such processes can affect the workflow of your system by flooding the process table and resources.
What causes zombie processes on Linux?
To understand the underlying cause of a zombie process in detail, you need to learn how to start and stop processes on Linux. The Linux operating system monitors all running processes and daemons on a computer. The Process table is a list of structures that contains all of the processes currently running on your computer.
Each process entry in the process table consists of a link to the Process control block this specific process. The circuit board stores the details associated with that particular process. These details include:
- Process status: The current status of the process
- Process number: A unique number that identifies the process
- Program counter: Contains information about the next instruction
- register: List of all CPU registers used by the process
- Open file list: Files used by the process
- Information on CPU planning: Contains information about the CPU time and the resources allocated to the process
- Storage management information: Provides details about the amount of memory used by the process
- I / O information: List of input or output devices used by the process
Linux uses the following process states to describe all of its processes.
- R.: Process is running
- S.: Sleep process
- D.: Uninterrupted sleep process
- T.: Process ended
- Z.: Zombie trial
Whenever a process completes the assigned task, its process status is set to zombie or Z.. Each process has a parent process that calls a family of functions called waiting() that waits for the state of a process to change. For example, if the process status changes from To run to zombie, the waiting() Method is triggered.
The waiting() The method usually deletes the process control block related to that zombie process, and then removes that process's entry from the process table.
But sometimes the higher-level process does not call this because of the poor development of a program waiting() Function. As a result, the system does not erase the zombie process circuit board. The process table entry for that particular process is also retained.
This grants the zombie process an infinite lifespan. Since the system cannot kill the process, the process entry is never deleted and the PID is never released.
How do I find zombie processes?
The first step in removing zombie processes from your system is to analyze which process has them zombie Process status. While you cannot terminate these processes directly because the system has already removed them from memory, you can terminate the parent process associated with them.
First of all, you need to check if your system's process table contains a zombie process. You can just do this with the above Command. Just open your terminal and type:
You will see output similar to this one. Notice the number of zombie processes at the top of the terminal window. If the output is zero then there is nothing to worry about.
You can list information about these zombie processes by passing the ps command along egrep. Egrep is an extension of the grep command on Linux that treats all patterns as an extended regex string.
Enter the following command to list all zombie processes:
ps aux | egrep "Z | defunct"
The above command looks for lines that contain either Z. or deceased in the output generated by the ps command. The output consists of a list of the zombie processes running on your system.
Killing zombie processes with the kill command
Now that you know which zombie processes are currently consuming your system resources, it is time to kill those processes.
While the easiest way to end zombie processes is to restart your computer, sometimes it isn't a viable option, especially if you are managing a server.
To kill zombie processes without shutting down your server, write down the process ID of a zombie process. From the previous section we can see that the PID of the zombie process was 18614. Then use this PID to determine the ID of the parent process.
ps -o ppid = -p 18614
Use to verify that the parent process ID exists ps Command.
ps -e | grep 18613
Now that we have confirmed the existence of the parent process, it is time to end it. Pass the -SIGKILL Flag with the kill Command as follows:
sudo kill -SIGKILL 18613
Once you finish the parent process, the system will delete the zombie process and automatically remove it from the process table.
Efficient management of processes under Linux
Every system administrator must prioritize monitoring processes running on a Linux computer. While zombie processes are not necessarily harmful to your system, they can cause performance problems if they are present in large numbers.
If you're a novice Linux user and have no idea how the Linux operating system manages processes, learning what processes are first is a good place to start.
What is a process on Linux?
Understanding processes and jobs is an important aspect of getting a grip on Linux. Here's what you need to know.
About the author
(45 articles published)
Deepesh is the junior editor for Linux at MUO. He has been writing informational content on the Internet for over 3 years. In his spare time he enjoys writing, listening to music and playing the guitar.
From Deepesh Sharma
Subscribe to our newsletter
Sign up for our newsletter to receive tech tips, reviews, free e-books, and exclusive offers!
One more step …!
Please confirm your email address in the email we just sent you.