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
 3836

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

link|improve this question

6  
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
feedback

4 Answers

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.

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

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.

link|improve this answer
2  
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
feedback

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

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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