Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

share|improve this question
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
up vote 8 down vote accepted

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

$ pkill "process name here"
share|improve this answer
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

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
share|improve this answer

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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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