杀死一系列进程

发布于 2024-10-07 03:50:38 字数 1815 浏览 3 评论 0原文

当我输入命令 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>

我想终止最后一列为 defunct 的所有进程。

有人可以帮我写一个脚本吗?

When I enter the command ps -ef |grep sharatds , I get a list of processes.

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>

I want to kill all the processes which have the last column as defunct .

Can anybody help me with a script ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

め可乐爱微笑 2024-10-14 03:50:38

这会做:

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

This will do:

ps -ef | grep sharatds | awk '{print $2}' | xargs kill
像极了他 2024-10-14 03:50:38

我通常会做这样的事情:

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

编辑:等等!这些是已失效的进程。他们已经死了,不能再杀了!父进程必须运行 wait() 来读取它们的状态,以便将它们清理并从进程表中删除。

I usually do something like this:

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

Edit: Wait! Those are defunct processes. They are already dead, and cannot be killed further! The parent process will have to run wait() to read their statuses so that they can be cleaned up and removed from the process table.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文