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. Feb 4, 2011 at 3:10

3 Answers 3


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

$ pkill "process name here"
  • 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
    – phemmer
    Feb 3, 2011 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

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .