平時很多時候發現定時檢測的指令碼kill 之後,該進程會僵死在裡面,無法清理。可以參考下面的方法清理:
有以下環境的進程:
#ps aux |grep monitorast.pl
root 3962 0.0 1.5 5652 3840 ? Ss 10:13 0:00 /usr/bin/perl -w /root/script/monitorast.pl
root 5135 0.0 0.2 3920 740 pts/0 S+ 10:52 0:00 grep monitorast.pl
# kill -9 3962 之後的進程狀態:
# ps aux |grep monitorast.pl
root 3962 0.0 0.0 0 0 ? Zs 10:13 0:00 [monitorast.pl] <defunct>
root 5196 0.0 0.2 3916 668 pts/0 R+ 10:52 0:00 grep monitorast.pl
之後再無法使用kill 來清除,那麼要清理必須從調用的進程處來kill
#ps axjf
1 2616 2616 2616 ? -1 Ss 0 0:00 crond
2616 3960 2616 2616 ? -1 S 0 0:00 /_ crond
3960 3962 3962 3962 ? -1 Zs 0 0:00 /_ [monitorast.pl] <defunct>
3960 3970 2616 2616 ? -1 S 51 0:00 /_ /usr/sbin/sendmail -FCronDaemon -i -odi -oem -oi -t
經過這裡的判斷,調用的進程沒有影響系統的其他任務在運行,所以可以直接kill父進程。
# kill -9 3960
# ps aux |grep monitorast.pl
root 5364 0.0 0.2 3916 676 pts/0 R+ 10:58 0:00 grep monitorast.pl
現在可以看到現在沒有啦。