将启动命令中包含某个字符串的进行杀死

1
2
3
4
[root@dn01 testbash]# ps -ef | grep hello
root 24794 7457 0 11:09 pts/2 00:00:00 sh hello.sh
root 24910 7457 0 11:09 pts/2 00:00:00 sh hello.sh
root 25295 7457 0 11:11 pts/2 00:00:00 grep hello

使用

1
ps aux | grep hello | grep -v grep |awk '{print $2}'| xargs kill -9

可以将上述的前两个进程杀死

Share