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/
Posted on February 9, 2010, in Linux Administration. Bookmark the permalink. Leave a comment.
Leave a comment
Comments 0