[K12OSN] a script for killing all users
Tom Wolfe
twolfe at sawback.com
Thu Oct 9 18:13:58 UTC 2008
In the past I've seen discussions on killing all users. I adapted the
script killer.sh as follows and it seems to work well. I replaced the "who
-u" with "ps aux" because it seems sometimes some users aren't in the who
-u list. I run it at night to keep things clean.
Comments would be welcome. Also, if anyone has a script to kill idle user
sessions that would be great -- that's next on my to do list.
### This defines USERS using the ps command
USERS=`ps aux | cut -f1 -d ' ' | sort -u`
### I don't want local machine accounts to be killed,
### just my Active Directory domain ones. The funny USER
### addition is to remove the first line of the ps command
NO_TOUCH_USERS=`cat /etc/passwd | cut -f1 -d ':'`\ USER
for user in $USERS; do
echo $user
GO=1
for no_user in $NO_TOUCH_USERS; do
if [ $no_user = $user ]; then
# echo NOT killing $user
GO=0
fi
done
if [ $GO = 1 ]; then
# echo killing $user
skill -KILL -u $user
sleep 1
skill -KILL -u $user
fi
done
More information about the K12OSN
mailing list