当我输入命令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>
我想要杀死所有最后一列已失效的进程。
有人可以帮我写一个剧本吗?
答案 0 :(得分:7)
这样做:
ps -ef | grep sharatds | awk '{print $2}' | xargs kill
答案 1 :(得分:4)
我通常做这样的事情:
kill $(ps -ef |grep sharatds|awk '{print $2}')
编辑等等!那些已经不复存在的过程。他们已经死了,不能再被杀死了!父进程必须运行wait()
才能读取其状态,以便可以清除它们并从进程表中删除它们。