mercoledì 22 gennaio 2014

UBUNTU - How to kill several process with the same string in their name

new post

sudo kill -9 $( pgrep sshd )

sshd is the command to kill, easier then the old post


old post

Simply open Your terminal ctrl+alt+T an type


fem@ordinateur:~$ ps -ef | grep ingularity | awk '{print$2}' | xargs kill -9



Let's analyze the code....


fem@ordinateur:~$ ps -ef | grep ingularity

give the output of current processes filtering them with the "ingularity" string.


fem@ordinateur:~$ ps -ef | grep ingularity | awk '{print$2}'


Then pipe the output to awk that extract the pid and print them (the second column only).


fem@ordinateur:~$ ps -ef | grep ingularity | awk '{print$2}' | xargs kill -9


 Then pipe again sending to xargs and kill to terminate the pid found

Bye