2010-12-13 49 views
3

當我輸入命令ps -ef | grep sharatds時,我得到一個進程列表。查殺一系列進程

sharatds 13164 13163 0 20:53 pts/2 00:00:00 [bt.C.256] <defunct> 
sharatds 13165 13163 0 20:53 pts/2 00:00:00 [rsh] <defunct> 
sharatds 13199 13163 0 20:53 pts/2 00:00:00 [rsh] <defunct> 
sharatds 13233 13163 0 20:53 pts/2 00:00:00 [rsh] <defunct> 
sharatds 13267 13163 0 20:53 pts/2 00:00:00 [rsh] <defunct> 
sharatds 13301 13163 0 20:53 pts/2 00:00:00 [rsh] <defunct> 
sharatds 13335 13163 0 20:53 pts/2 00:00:00 [rsh] <defunct> 
sharatds 13369 13163 0 20:53 pts/2 00:00:00 [rsh] <defunct> 
sharatds 13403 13163 0 20:53 pts/2 00:00:00 [rsh] <defunct> 
sharatds 13437 13163 0 20:53 pts/2 00:00:00 [rsh] <defunct> 
sharatds 13471 13163 0 20:53 pts/2 00:00:00 [rsh] <defunct> 
sharatds 13505 13163 0 20:53 pts/2 00:00:00 [rsh] <defunct> 
sharatds 13539 13163 0 20:53 pts/2 00:00:00 [rsh] <defunct> 
sharatds 13573 13163 0 20:53 pts/2 00:00:00 [rsh] <defunct> 
sharatds 13607 13163 0 20:53 pts/2 00:00:00 [rsh] <defunct> 
sharatds 13641 13163 0 20:53 pts/2 00:00:00 [rsh] <defunct> 
sharatds 13675 13163 0 20:53 pts/2 00:00:00 [rsh] <defunct> 
sharatds 13709 13163 0 20:53 pts/2 00:00:00 [rsh] <defunct> 
sharatds 13743 13163 0 20:53 pts/2 00:00:00 [rsh] <defunct> 
sharatds 13777 13163 0 20:53 pts/2 00:00:00 [rsh] <defunct> 
sharatds 13811 13163 0 20:53 pts/2 00:00:00 [rsh] <defunct> 
sharatds 13845 13163 0 20:53 pts/2 00:00:00 [rsh] <defunct> 
sharatds 13879 13163 0 20:53 pts/2 00:00:00 [rsh] <defunct> 
sharatds 13913 13163 0 20:53 pts/2 00:00:00 [rsh] <defunct> 

我想殺死所有最後一列已失效的進程。

任何人都可以幫我一個腳本?

+3

如果可以的話,最好避免使用'ps'。如果可用,請使用'pgrep -u'或'pkill -u';如果不可用,請使用'ps -u'。使用'grep'存在誤報的風險。布蘭登是對的。他們已經死了。 – 2010-12-13 02:28:26

回答

7

這樣做:

ps -ef | grep sharatds | awk '{print $2}' | xargs kill 
4

我平時做這樣的事情:

kill $(ps -ef |grep sharatds|awk '{print $2}') 

編輯:等待!這些都是不存在的過程。他們已經死了,不能再被殺死!父進程必須運行wait()來讀取它們的狀態,以便將它們清理並從進程表中刪除。

+1

我真的很喜歡這種方法,很高興地注意到,如果你想在案例中「超殺」它,你也可以做'sudo kill -9 $(ps -ef | grep sharatds | awk'{print $ 2}')''常規殺死不起作用。 (不過對於心靈的隱隱)LOL – 2016-11-07 03:48:03

+0

或者殺死父母的過程。當父母死亡時,孩子們被自動收穫殭屍孩子的init(進程1)繼承。 – anthony 2017-12-20 01:47:21