How to give arguments to kill via pipe

2019-01-30 08:15发布

I need to search for a certain process and kill that process. I wrote a command like this:

ps -e | grep dmn | awk '{print $1}' | kill

Where the process name is dmn. But it is not working. How can I find processes by name and kill them.

9条回答
不美不萌又怎样
2楼-- · 2019-01-30 08:32

Just adding on others, but I like using awk's regex features capacity:

kill $(ps | awk '/dmn/{print $1}')
查看更多
神经病院院长
3楼-- · 2019-01-30 08:32
for procid in $(ps -aux | grep "some search" | awk '{print $2}'); do kill -9 $procid; done

hello friends .. we can do it using for loop .

"Some search" is here any process name you want to search, for example "java" so let say count of java process is 200+ so killing one by one will be too typical .

so you can use above command.

Thanks.

查看更多
叛逆
4楼-- · 2019-01-30 08:44

You could use

pkill dmn 

if your system has the pkill command.

查看更多
登录 后发表回答