How Linux servers Find and kill zombie processes

Source: Internet
Author: User

First, we can use the top command to see whether the server currently has a zombie process, in the following figure can see the number of zombie processes, if the number is greater than 0, it means that the server currently has a zombie process

Below, we use the PS and grep commands to find the zombie process

Ps-a-ostat,ppid,pid,cmd | Grep-e ' ^[zz] '

command annotation:

-A parameter lists all processes

-O Custom output fields We set the Display field stat (state), PPID (process parent ID), PID (process id), cmd (command) These four parameters

Because the process of a state of Z or Z is a zombie process, we use grep to crawl the stat state for the ZZ process

The results of the operation refer to the following

Z 12334 12339/path/cmd

At this point, we can use kill-hup 12339来 to kill this zombie process.

After running, you can run Ps-a-ostat,ppid,pid,cmd again | Grep-e ' ^[zz] ' to confirm the killing of the zombie process

If the kill child process is invalid, you can try to kill its parent process to resolve the problem, for example, the parent process PID is 12334 above, so we run

Kill-hup 12334

To solve the problem

June 9, 2014 add

Check current zombie Process information

Ps-ef | grep defunct | Grep-v grep | Wc-l

View top two lines of information

Top | Head-2

Kill the process directly.

Ps-ef | grep defunct | Grep-v grep | awk ' {print ' kill-18 ' $} '

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.