bash - 杀死一系列进程

标签 bash awk kill

当我输入命令 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 的进程。

谁能帮我写一个脚本?

最佳答案

这样做会:

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

关于bash - 杀死一系列进程,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4425305/

相关文章:

linux - 从日志文件中搜索值和计数

Bash 嵌套循环从文件中读取行

bash - bash 中 if 语句与 test 命令的比较未按预期工作

awk - 将多个字符串替换 awk 命令合并为一个

linux - 如何在 Linux 上按名称而不是 PID 杀死进程?

linux - 使用 sed 从列表中删除 IPv6 地址

regex - 如何将引号中的多行数据恢复为一行?

linux - 从列中减去常数

ios - 如何杀死 Vapor 服务器

bash - 如何让脚本在特定时间后运行后自行终止?