Linux: Kill a Process from the Command Line Without Knowing the PID

So we have a script – – which is running on a linux box and we want to kill it quickly with the minimum of fuss:

root@linux# kill $(pgrep <script_name>)

Here is the explanation:

We use “pgrep” to grep the running process list and returns a process’s PID :

[root@linux]# pgrep

And combine it with the kill command to make a one-liner:

[root@linux]# kill $(pgrep

More info on pgrep and kill on the man pages:

Leave a ReplyCancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Exit mobile version