Best way to kill Zombie and D state processes in linux

50,901

Solution 1

Double tap.

Actually, reboot. There's no real way to easily get rid of a zombie, but there's really no reason to because a zombie isn't taking up resources on the computer; it's an orphaned entry in a process table. Init is supposed to collect it but something went wrong with the process. http://en.wikipedia.org/wiki/Zombie_process

Perhaps you're asking because there's worse problem...are you getting a boatload of zombies roaming your process table? That usually means a bug in the program or a problem with a configuration. You shouldn't have a huge number of zombies on the system. One or two I don't worry. If you have fifty of them from Apache or some other daemon, you probably have a problem. But that's not directly related to your question...

Solution 2

/sbin/reboot

You can't kill a zombie - its already dead

If the ppid still exists, then terminating that can often clean up the spawned zombies.

You shouldn't be killing processes in uninterruptible sleep - usually this means they're i/o bound, but IIRC it can also occur during a blocking read from e.g. a network socket.

Solution 3

Errors in underlying filesystem or disks might cause I/O bound processes. In this case try to "umount -f" the filesystem they depend upon - this will abort whatever outstanding I/O requests there are open.

Solution 4

Next line will kill all zombies

ps -xal | grep defunct | awk '{ system (" kill -9 " $4 ) }'
Share:
50,901

Related videos on Youtube

vnix27
Author by

vnix27

I am a linux administrator and IT security consultant. I am working on the profile of System administrator and working on RHEL platfrom from year 2006. I have samba,ldap and iptable stronghold.

Updated on September 17, 2022

Comments

  • vnix27
    vnix27 over 1 year

    What is the best way to kill Zombie processes and D state process by single command.

  • vnix27
    vnix27 about 13 years
    there are around 10 zombie process
  • user1364702
    user1364702 about 13 years
    What are the processes?
  • Michael Hampton
    Michael Hampton about 10 years
    And lose data. Doesn't sound like a great idea.
  • Arie Skliarouk
    Arie Skliarouk about 10 years
    You lose data anyway by reboot. This way you might avoid reboot - useful feature on production or development systems.
  • BT643
    BT643 over 9 years
    Thanks, this worked for an issue we had with a script stuck attempting to access a disappeared NFS mount for weeks :)
  • Marco Marsala
    Marco Marsala over 8 years
    This is exactly what is happening to me sometimes when I do the ls command on a s3fs mount. The ls process won't kill even with kill -9 until I force the unmount with umount -l. Alternatives to umount?
  • Dustin Oprea
    Dustin Oprea over 7 years
    @ArieSkliarouk Freaking awesome. Thanks for this little tidbit.
  • Curtis Yallop
    Curtis Yallop almost 7 years
    Now my umount process is hung as a zombie STAT "D+"!
  • Tim Chaubet
    Tim Chaubet about 2 years
    This might also kill the ssh shell you're connected with.