Kill the undesired UNIX processes in one go

本文提供了一种方法,通过组合使用ps、grep和awk,快速杀死属于特定用户的或匹配特定正则表达式的UNIX进程。操作步骤简洁明了,帮助用户有效管理进程。

Kill the undesired UNIX processes in one go

Kill the undesired UNIX processes in one go

Contributor IconContributed by roshi  
Tag IconTagged: UNIX  

This recipe is useful when one wants to kill all the processes belonging to one user or having a particular regular expression in the process name.
One can use different options of “ps” and “grep” to kill the undesired process(es).


The following is the general syntax of this recipe

ps -u | grep
| awk '{print $1}' | xargs kill -9

ps -u will find all the processes of the user username.
This output is then greped for processname_pattern which is then piped to awk.
awk ‘{print $1}’ will print only the first column of the output (the process-id, in this case).
This is then xargd to the kill with sure kill -9 signal.

As a result,all the undesired processes will be killed.

Note : One should give the processname_pattern carefully as an incorrect
regular expression may lead to even desired processes being killed.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值