CentOS下下殺殭屍進程辦法

來源:互聯網
上載者:User

1) 檢查當前殭屍進程資訊

  # ps -ef | grep defunct | grep -v grep | wc -l

  175

  # top | head -2

  top - 15:05:54 up 97 days, 23:49, 4 users, load average: 0.66, 0.45, 0.39

  Tasks: 829 total, 1 running, 479 sleeping, 174 stopped, 175 zombie

  # ps -ef | grep defunct | grep -v grep

  2) 獲得殺殭屍進程語句

  # ps -ef | grep defunct | grep -v grep | awk '{print "kill -9 " $2,$3}'

  執行上面獲得的語句即可, 使用訊號量9, 殭屍進程數會大大減少.

  3) 過一會兒檢查當前殭屍進程資訊

  # ps -ef | grep defunct | grep -v grep | wc -l

  125

  # top | head -2

  top - 15:29:26 up 98 days, 12 min, 7 users, load average: 0.27, 0.54, 0.56

  Tasks: 632 total, 1 running, 381 sleeping, 125 stopped, 125 zombie

  發現殭屍進程數減少了一些, 但還有不少啊.

  4) 再次獲得殺殭屍進程語句

  # ps -ef | grep defunct | grep -v grep | awk '{print "kill -18 " $3}'

  執行上面獲得的語句即可, 這次使用訊號量18殺其父進程, 殭屍進程應該會全部消失.

  5) 過一會兒再檢查當前殭屍進程資訊

  # ps -ef | grep defunct | grep -v grep | wc -l

  0

  # top | head -2

  top - 15:39:46 up 98 days, 23 min, 7 users, load average: 5.46, 2.20, 1.12

  Tasks: 134 total, 1 running, 133 sleeping, 0 stopped, 0 zombie

  6) 清除ZOMBIE(殭屍)進程原理

  # kill -18 PPID

  PPID是其父進程, 這個訊號是告訴父進程, 該子進程已經死亡了, 請收回分配給他的資源. 如果還不行則看先看其父進程又無其他子進程, 如果有, 可能需要先kill其他子進程, 也就是兄弟進程.

  方法是:

  # kill -15 PID1 PID2

  PID1,PID2是殭屍進程的父進程的其它子進程.

  然後再kill父進程:

  # kill -15 PPID

  --End--


聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.