Program to log off idle users
#Eugen Bauknecht
eugen at hpbbi4.BBN.HP.COM
Mon Oct 1 19:54:23 AEST 1990
I am using a script which I called " killuser " and which is started by cron
every 10 minutes or so.
Hope this helps
===================================================================
# killuser
# kills all users, whose processes are idle longer than 1 hour.
who -u | awk '{print $2,$6}' > /tmp/kltmp0
cat /tmp/kltmp0 | awk '{ if ($2>=1) print $1 }' >> /tmp/kltmp1
var=`cat /tmp/kltmp1` ;export var
for i in $var
do
ps -ft $i >> /tmp/kltmp2
done
cat /tmp/kltmp2 2>/dev/null| awk '{if ($2 !="PID") print $2}' >>/tmp/kltmp3
sort -rn -o/tmp/kltmp4 /tmp/kltmp3
var=`cat /tmp/kltmp4`
kill -9 `echo $var` 2>/dev/null
rm /tmp/kltmp* 2>/dev/null
#end
More information about the Comp.unix.admin
mailing list