1

So, I want to send a kill to a process, I know it's name

ps -ef | grep '_rails master'
root      2388     1  0 19:46 ?        00:00:04 unicorn_rails master -c /web/hero/config/unicorn.rb -E production -D                   
root      2582  2172  0 20:28 pts/0    00:00:00 grep --color=auto _rails master

It is unicorn_rails master [..] how do I kill it?

I tried so far: sed and expr. But cant pass it as param to kill

  • Note that system services often come with start/stop scripts that do this work for you. I have no idea but maybe this unicorn_rails might have something like that under /etc/init.d for example. – Phil Hollenback Feb 4 '11 at 3:10
9

There exists a more direct command called pkill. Usage is as follows:

$ pkill "process name here"
| improve this answer | |
  • 4
    also do pkill -f 'unicorn_rails master' if theres going to be multiple instances of the program running and you only want to kill that one – Patrick Feb 3 '11 at 22:41
1

You can the command:

$ sudo kill `pidof process_name`.

You can use also:

$ sudo killall process_name

If you want to use grep, you can try:

$ ps -ef | grep '_rails master' | grep -v grep | awk '{print $3}' | sudo kill
| improve this answer | |
1

You can use the following:

ps -ef | grep [u]nicorn_rails | awk '{print $2}' | sudo xargs kill

Note, the [] in 'grep [u]nicorn_rails' keeps you from matching on the grep command in the ps tree.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.