O'Reilly Hacks
oreilly.comO'Reilly NetworkSafari BookshelfConferences Sign In/My Account | View Cart   
Book List Learning Lab PDFs O'Reilly Gear Newsletters Press Room Jobs  

Slay a type of process owned by a user
Need to kill a set of processes quick and dirty? Here's a somewhat safe way to do it.

Contributed by:
Unknown User anonymous2
[02/19/04 | Discuss (4) | Link to this hack]

user: foobar
process name: myprogram

kill `ps aux | grep -E '^foobar' | grep myprogram | awk '{ print $2 }'`

Of course, this is just killing a list of pids - you can use the line without the kill + backticks just to get a list of pids.

And always, there is the program 'slay', which will do this for you much easier. However, slay is not available on most systems so you're better off using this instead.

Haven't tested on a SysV ps.

O'Reilly Home | Privacy Policy

© 2007 O'Reilly Media, Inc.
Website: | Customer Service: | Book issues:

All trademarks and registered trademarks appearing on oreilly.com are the property of their respective owners.