grep - How to kill all process with given name? - Unix & Linux Stack Exchange
The problem is that ps -A | grep <application_name> | xargs -n1
returns output like this
19440 ? 00:00:11 <application_name> 21630 ? 00:00:00 <application_name> 22694 ? 00:00:00 <application_name>
You can use awk
to a get first a column of ps
output.
ps -A | grep <application_name> | awk '{print $1}' | xargs -n1
Will return list of PIDs
19440 21630 22694
And adding kill -9 $1
you have a command which kills all PIDs
ps -A | grep <application_name> | awk '{print $1}' | xargs kill -9 $1
Read full article from grep - How to kill all process with given name? - Unix & Linux Stack Exchange
No comments:
Post a Comment