Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

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

I run a script called "delayed_job" for a Ruby on Rails application. One of the options is to run this proc with a separate monitor proc. When the main proc dies, the monitor will spawn a new one. I can also run multiple processes. Each will have its own associated monitor process.

The script gives a way to kill the main processes, but not the monitor processes. I want to kill all of them.

A command of:

ps -ef|grep delayed


42011    29423     1  0 Sep25 ?        00:00:02 delayed_job.0_monitor                
42011    29428     1  0 Sep25 ?        00:00:02 delayed_job.1_monitor                
42011    29434     1  0 Sep25 ?        00:00:02 delayed_job.2_monitor                
42011    29437     1  0 Sep25 ?        00:00:01 delayed_job.3_monitor                
42011    23359     1 10 Oct19 ?        03:12:49 delayed_job.0                        
42011     8607     1  5 Oct19 ?        00:58:42 delayed_job.3                        
42011    21442     1 44 12:31 ?        01:02:03 delayed_job.2                        
42011    23092     1  4 14:18 ?        00:01:22 delayed_job.1                        
42011    23861 23763  0 14:51 pts/5    00:00:00 grep delayed

I want to kill all of them, or at least the monitors. How can I kill these (with the exception of the grep command itself)?

share|improve this question
up vote 5 down vote accepted has a nice write up of the usual answer for generic unix: pipe ps to grep, then to awk, then to xargs.

As another poster mentioned, beware any glib answer that throws around "killall", since it has a radically different purpose on AIX and Solaris (at least) than it does on Linux. Running killall as root on Solaris is a "resume generating event".

share|improve this answer

If you are running a linux machine, the killall command seems to be what you are looking for.

share|improve this answer

pkill and killall are variants of this.

# pkill vim

# killall vim

Both has extended documentation in their respective man-pages.

share|improve this answer

Outside of the above pkill and killall answers, you can do the following, assuming you want to kill process "foo"

ps -ef | grep [f]oo | awk {'print $1'} | xargs kill

The grep [f]oo means that grep will not match the grep command itself, so it will just kill processes named "foo".

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.