Date: 16 Dec 1997 04:15:29 +0200 From: Vladimir Litovka <doka@grunt.vl.net.ua-nospam> To: freebsd-isp@freebsd.org Subject: Yet another killall ;) Message-ID: <674o81$a3e$1@grunt.vl.net.ua>
next in thread | raw e-mail | index | archive | help
Hi! There is another killall I wrote. This is oftenly used utility, and killall in standart distribution doesn't give me, what I need. Usage: killall [-SIG] process1 [process2 ... processN] it kills processes either if process started with full path (i.e. /path/to/program) or via shell (for example: /bin/sh /etc/ppp/PPP) It doesn't kills shells - this is feature, inherited from previous feature ;) As usualy - comments and questions ;) ======================================================= #!/usr/local/bin/bash # # (c) 1997, Vladimir Litovka <doka@grunt.vl.net.ua> # v1.1b+, 12/12/1997 # Check, if first argument is signal number (-xx) # If no, set to default -15 if [ -n "$1" ]; then if [ `echo $1 | cut -c 1-1` = "-" ]; then S=$1; shift else S="-15"; fi fi # Insert between all process names '|' for egrep while [ -n "$1" ]; do if [ -n "$P" ]; then fP=$fP"|"$1\$; P=$P"|"$1 else fP="^[0-9]+ $1\$"; P=$1; fi shift done if [ ! -n "$P" ]; then echo Usage: $0 [-SIG] process1 [process2 ... processN] exit fi ids=`ps axo"pid,command" 2>/dev/null |egrep $P | awk '{if ($2 ~ /\/sh$|\/bash$|\/csh$|\/tcsh$|\/ksh$/) print $1,$3; else print $1,$2}' | egrep $P | awk 'BEGIN {FS="[ /]"} {print $1, $NF}' |egrep "$fP" | awk '{print $1}'` # For debugging purposes echo Killing \($ids\) by $S signal if [ -n "$ids" ]; then kill $S $ids 2>/dev/null >/dev/null nokilled=$? else nokilled=1 fi if [ $nokilled -eq 1 ]; then echo No processes killed fi ===================================================== -- Vladimir Litovka <doka@grunt.vl.net.ua>, hostmaster of vl.net.ua ---------------- Don't trouble trouble until trouble troubles you
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?674o81$a3e$1>