Killing the correct process
Bill Petro SunOS Marketing
rock%warp at Sun.COM
Tue Feb 13 07:38:20 AEST 1990
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
More information about the Comp.unix.questions
mailing list