Kill the undesired UNIX processes in one go
Kill the undesired UNIX processes in one go
Contributed by roshi
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 -9ps -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.
in Share