Some versions of *nix don't support a TMOUT variable, so the following script might be useful to those administrators who wish to kill users after a period of inactivity longer than two hours. Please note that this script was written with Oracle users in mind, but should work for others too. This is it:
USERS=`finger | wc -l` if [ $USERS -gt 40 ] then rm users 2>/dev/null finger -i > times grep hours times > times1 cat times1 | tr -s ' ' ' ' | cut -f1 -d' ' > times2 for i in `cat times2` do ps -ef |grep $i | grep -v root| tr -s ' ' ' ' | cut -f4 -d' ' >> users done cat users | while read number do kill $number 2>/dev/null done else exit fi
I run this script every hour from cron. If there are no more than 40 users on the system, no action is taken.