I need to kill a process that contains myName
in its description. Currently I'm doing:
ps -ax |grep myName
I see PID
kill -9 PID
How can I do the same with one command without entering the PID?
bashcommand lineprocess
I need to kill a process that contains myName
in its description. Currently I'm doing:
ps -ax |grep myName
I see PID
kill -9 PID
How can I do the same with one command without entering the PID?
Best Answer
If
myName
is the name of the process/executable which you want to kill, you can use:pkill
by default sends theSIGTERM
signal (signal 15). If you want theSIGKILL
or signal 9, use:If
myName
is not the process name or for example, is an argument to another (long) command,pkill
(orpgrep
) might not work as expected. So you need to use the-f
option. Fromman kill
:So:
or