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

So we have a script – myscript.sh – 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 myscript.sh
20104

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

[root@linux]# kill $(pgrep myscript.sh)
[root@linux]#

More info on pgrep and kill on the man pages:
http://linux.die.net/man/1/pgrep

http://linux.die.net/man/2/kill

One Reply to “Linux: Kill a Process from the Command Line Without Knowing the PID”

  1. [465]3333 Official Login | সেরা অনলাইন ক্যাসিনো ও স্লট গেমস,3333 অ্যাপ ডাউনলোড করে সেরা অনলাইন ক্যাসিনো গেমসের অভিজ্ঞতা নিন। এখানে বিকাশ দিয়ে সহজ ডিপোজিট পদ্ধতি এবং স্লট গেম খেলার নিয়ম জানা যাবে। আজই যোগ দিন। visit: 3333

Leave a Reply

Your email address will not be published. Required fields are marked *