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 keep running these two commands over and over:

$ ps aux | grep php | grep -v grep
www-data  3663  100 14.8 328620 304900 ?       R    12:56   0:54 php /home/jason/projects/mcif/./symfony import:process --id=91
jason@gob:~/projects/mcif$ sudo kill 3663

Is there a quick and easy way to just grab the pid and kill that? The closest I've come is this:

$ ps aux | grep php | egrep -o ' [0-9]+ ' | head -n1

But I don't know how to pipe that through kill.

share|improve this question
This question title could be used for the entire history of humankind... – gWaldo Nov 1 '10 at 17:56
There are days I feel the same way. – Dennis Williamson Nov 1 '10 at 18:03
+1 for the title – Joshua Enfield Nov 1 '10 at 21:17
up vote 7 down vote accepted

pkill will do what you're asking for here.

Before you execute a pkill, try a pgrep first to make sure you're matching what you expect to be.

share|improve this answer
sudo pkill php did it. Thanks. – Jason Swett Nov 1 '10 at 17:17

You can also use "killall", which takes the name of a process and kills it. It takes the same args as kill.

You'd use "killall symfony" for your example.

share|improve this answer
Make a mental note though that if one day you use "killall" in a Solaris machine it will kill all active processes – adamo Nov 1 '10 at 21:23

I am using zap on OpenBSD (it is not on the base system).

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.