Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cs.utexas.edu!usc!brutus.cs.uiuc.edu!apple!sun-barr!newstop!sun!warp!rock From: rock%warp@Sun.COM (Bill Petro (SunOS Marketing)) Newsgroups: comp.unix.questions Subject: Re: Killing the correct process Message-ID: <131696@sun.Eng.Sun.COM> Date: 12 Feb 90 20:38:20 GMT References: <22332@adm.BRL.MIL> <5312@star.cs.vu.nl> <1212@root44.co.uk> <5352@star.cs.vu.nl> Sender: news@sun.Eng.Sun.COM Lines: 51 I don't know if this is appropriate, but here is a handy little tool I use: ------------------- Cut here, valuable coupon, collect 'em all -------- #!/bin/sh # # killjobs # # Do our best to locate the PIDs to kill from the give # process names. # MYNAME=`basename $0` Ask=yes case $1 in "") echo "Usage: $MYNAME process_name ..." exit 1 ;; -n) Ask=no; shift ;; esac PSAX=`ps ax` for pname do line= PID= PID=`echo "$PSAX" | grep -w $pname | awk '!/grep|'$MYNAME'/ {print $1}'` for pid in $PID do if [ $Ask = yes ] then line=`echo "$PSAX" | awk '$1 == '$pid' {print}'` echo -n "Kill ($line)? " read reply case $reply in [Yy]*) kill -9 $pid ;; esac else kill -9 $pid fi done done ------------ end ---------------------------------------------- Bill Petro {decwrl,hplabs,ucbvax}!sun!Eng!rock "UNIX for the sake of the kingdom of heaven" Matthew 19:12