KILL A LINUX PROCESS BY PROCESS NAME

If you have a situation where you need to find and kill a specific process by name or script name, you can use this command:

kill `ps -ef | grep YourProcessName | awk ‘{print $2}’`

This is invaluable in cases where the same process command (python, java, etc.) is being used for multiple scripts. For example, there are a few different python processes running on my webserver, but I only want to kill one of them. So, instead of using:

kill $(pidof python)

which kills the first python process, or:

killall -9 python

which kills ALL running python processes, I can just specify the process by the actual python script that is running.

Reference:
http://www.howtogeek.com/howto/ubuntu/kill-a-process-by-process-name-from-ubuntu-command-line/

Advertisements

Posted on February 9, 2010, in Linux Administration. Bookmark the permalink. Leave a comment.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: