[Sunhelp] kill script

Dennis L. Lund dllund at hermes.nextel.com
Tue Aug 15 11:04:34 CDT 2000


You can use this to kill a users process:

ps -ef | awk '/<param>/ {print $2}' | xargs kill

Or you could use this script:

#!/usr/bin/ksh
#
# This script will kill all user processes for the
# specified user.
#

if [[ "$1" != "" ]]
then
        User=$1
else
        read User?"Enter username: "
fi
for Proc in $(ps -fu$User|tail +2|awk '{print $2}'|sort -rn)
do
        kill $Proc
done

Dennis L. Lund
e-mail: dllund at hermes.nextel.com





More information about the SunHELP mailing list