# idletime.sh - Idle job kill demon
# will kill all jobs idle longer than 15 minutes
# mail a message to the offender and log this
# deed into /etc/idle.log
umask 077
set `who -u | awk '{print $1,$2,$3,$4,$5,$6,$7}'`

while true
do
name=$1
linetty=$2
month=$3
day=$4
logtime=$5
idle=$6
pid=$7

if [ $idle != "." ]
then
 if [ `echo $idle | cut -c3-4` -gt 15 ]
 then
 echo $name $linetty $month $day $logtime $idle $pid >> /etc/idle.log
 mail $name <<EOF

You have been found guilty of a UNIX Misdemeanor!

 Count One: HOGGING Resources by leaving your terminal logged in for
     a long period of time. (Over 15 minutes of inactivity)

 Count Two: Leaving the system exposed for others to peek at
     things that they have no business looking at.
     (WE Don't need Sight Seeing lurkers perusing though
     TOP SECRET Documents, and doing other unauthorized
     activities.) 

 Therefore: You will be taken to the UNIX Jail, at which time
     there will be great gnashing of teeth.
System Administrator
Msg-90/idle
EOF
 kill -9 $pid       
 fi
fi
shift; shift; shift; shift; shift; shift; shift
if [ $# -lt 7 ]   
then
 exit 0
fi
done

# EOF

