Lately I've been working with a few java applications and decided I'd really like a more convenient way of killing the processes.  What I wanted was essentially:

jkill <name>

With little help from http://ubuntuforums.org/member.php?u=93334, I decided on the following, which I like quite a bit:

#!/bin/bash
for pid in `ps -Ao pid,command | grep java | grep $1 | sed "s/^[ ]*//" | cut -d\  -f1`;
do 
   ps -p$pid --no-header -f 
   kill -@2 $pid
done
Comments:

-9 is a bit extreme, are they that hung they can't be killed normally?

Posted by Abraham Tehrani on March 10, 2009 at 06:44 PM EDT #

These are some hung processes I'm hunting,
But still very useful if you swap out the signal or maybe even just swap:
grep $@ -> $1
kill -9 -> kill @2

Posted by John Crepezzi on March 11, 2009 at 10:55 AM EDT #

Post a Comment:
  • HTML Syntax: NOT allowed

This blog copyright 2009 by John Crepezzi