Should I kill zombie process in my system?

20

2

Since I'm newbie in Linux/Unix systems and just read about zombie processes, I have one question. I have 10 of them right now. Do I need to kill them and if yes, why? Are they a load on my system?

592 processes: 581 sleeping, 1 running, 10 zombie, 0 stopped

Jason Paddle

Posted 2012-07-27T14:20:56.647

Reputation: 593

25No need to kill them. They are already dead. – Marco – 2012-07-27T14:23:21.160

2So they doesn't load my system anymore. And they will remain like this untill i reboot system or i kill them, right ? – Jason Paddle – 2012-07-27T14:26:14.910

7@Marco: You can't kill what's already dead. But you can kill its parents, harrharr! – wullxz – 2012-07-27T14:35:59.420

7The problem is that their parent did not reap them (when they died). – ypercubeᵀᴹ – 2012-07-27T14:40:01.157

2You see how much this is a gamer's community by the whole zombie-killing feeling in this thread. – Camilo Martin – 2012-07-27T18:34:22.773

310 zombies ??? You are infested! Run Jason run. – Luc M – 2012-07-27T19:56:44.853

Answers

29

You cannot kill a zombie, it is already dead.

The resources of that process are free and available to other processes. What remains is an entry in the process table. This does not have an influence on the performance, don't worry.

Marco

Posted 2012-07-27T14:20:56.647

Reputation: 4 015

I use Ubuntu. My machine sometimes slows down inexplicably. When I check top, I invariably see zombie processes. When I kill the zombies, performance returns. I don't know much about this, but I find it hard to believe that zombies have no influence on performance.. – user3516726 – 2019-04-16T19:28:34.673

Yes, this make sense. I can kill parent process. Thank you for the info. I just wanted to know if they load or no system. – Jason Paddle – 2012-07-27T14:33:24.697

I believe there is a limit of zombies though. I think its 1024, so it wont hurt performance but I think there is a ceiling on the number you can have. – ProfessionalAmateur – 2012-07-27T15:12:13.867

@ProfessionalAmateur What happens if you hit the zombie limit (1024 or whatever)? – Roddy of the Frozen Peas – 2012-07-27T19:46:22.607

@RoddyoftheFrozenPeas - To be honest Im not sure, Ive always cleaned them up prior to getting to that point. I imagine the system will try to create another zombie and perhaps have a memory violation or some other hard error, overflow or segmentation fault of some sort. – ProfessionalAmateur – 2012-07-27T21:07:16.000

2@ProfessionalAmateur: There is no zombie limit in linux. Zombie PIDs are subject to /proc/sys/kernel/pid_max, just like every other PID. – rsaw – 2012-07-28T01:30:50.477

@ryran - I asked here as well about max zombies, good info.

– ProfessionalAmateur – 2012-08-02T20:08:27.603

16

What are these zombie processes that show up in ps? I kill them but they don't go away!

Zombies are dead processes. You cannot kill the dead. All processes eventually die, and when they do they become zombies. They consume almost no resources, which is to be expected because they are dead! The reason for zombies is so the zombie's parent (process) can retrieve the zombie's exit status and resource usage statistics. The parent signals the operating system that it no longer needs the zombie by using one of the wait() system calls.

When a process dies, its child processes all become children of process number 1, which is the init process. Init is always waiting for children to die, so that they don't remain as zombies.

If you have zombie processes it means those zombies have not been waited for by their parent (look at PPID displayed by ps -l). You have three choices: Fix the parent process (make it wait); kill the parent; or live with it. Remember that living with it is not so hard because zombies take up little more than one extra line in the output of ps.

Source: http://www.linuxsa.org.au/tips/zombies.html

And in case you’re on a killing spree, this superuser thread might be interesting to you: How do you find the parent process of a zombie process?

wullxz

Posted 2012-07-27T14:20:56.647

Reputation: 2 400

Note that fixing the parent might be overkill - maybe it's just not got to the point of waiting for it's children yet. Maybe it'll do it later on (or yes, maybe it won't). – Romain – 2012-07-27T15:14:49.653

yes, you're right. The answer of the question I linked tells you how to determine the parent process. So you've always the chance to check which processes create the zombies and to decide if it's necessary to keep it running. – wullxz – 2012-07-27T15:22:06.230

7

You don't need to kill them.

To build up some basic understanding:

Every process is the child of a parent process (except for the init process, but we don't need to worry about that).

When a child process finishes executing, it might still contain data that the parent process wants to access, usually an exit code which describes the result of the child process (Did it succeed? Did it error? What was the error code?).

A finished child process hangs around in the process table as a zombie process until the parent process "reaps" or waits on the child process, which is simply the parent process telling the OS that it doesn't need that child process anymore; It has read any return values it wants, and is done with it. At this point, the system will clean up the entry in the process table.

Darth Android

Posted 2012-07-27T14:20:56.647

Reputation: 35 133

3

This process doesn't need to be killed.

Just in case you do want to kill it anyway (for whatever reason), make sure you shoot at the head, here is a useful command:

kill -HUP `ps -A -ostat,ppid | grep -e '^[Zz]' | awk '{print $2}'`

From https://www.erianna.com/kill-a-linux-zombie-process

Datageek

Posted 2012-07-27T14:20:56.647

Reputation: 166

1+1 for shoot at the head. – BenjiWiebe – 2014-06-24T02:04:05.777