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.

  • 8
    This question title could be used for the entire history of humankind...
    – gWaldo
    Nov 1, 2010 at 17:56
  • There are days I feel the same way. Nov 1, 2010 at 18:03

4 Answers 4


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.


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.

  • 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, 2010 at 21:23

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

You must log in to answer this question.

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