home *** CD-ROM | disk | FTP | other *** search
/ norge.freeshell.org (192.94.73.8) / 192.94.73.8.tar / 192.94.73.8 / pub / sdf / killer / idletime.sh < prev    next >
Text File  |  1990-01-31  |  1KB  |  53 lines

  1. # idletime.sh - Idle job kill demon
  2. # will kill all jobs idle longer than 15 minutes
  3. # mail a message to the offender and log this
  4. # deed into /etc/idle.log
  5. umask 077
  6. set `who -u | awk '{print $1,$2,$3,$4,$5,$6,$7}'`
  7.  
  8. while true
  9. do
  10. name=$1
  11. linetty=$2
  12. month=$3
  13. day=$4
  14. logtime=$5
  15. idle=$6
  16. pid=$7
  17.  
  18. if [ $idle != "." ]
  19. then
  20.  if [ `echo $idle | cut -c3-4` -gt 15 ]
  21.  then
  22.  echo $name $linetty $month $day $logtime $idle $pid >> /etc/idle.log
  23.  mail $name <<EOF
  24.  
  25. You have been found guilty of a UNIX Misdemeanor!
  26.  
  27.  Count One: HOGGING Resources by leaving your terminal logged in for
  28.      a long period of time. (Over 15 minutes of inactivity)
  29.  
  30.  Count Two: Leaving the system exposed for others to peek at
  31.      things that they have no business looking at.
  32.      (WE Don't need Sight Seeing lurkers perusing though
  33.      TOP SECRET Documents, and doing other unauthorized
  34.      activities.) 
  35.  
  36.  Therefore: You will be taken to the UNIX Jail, at which time
  37.      there will be great gnashing of teeth.
  38. System Administrator
  39. Msg-90/idle
  40. EOF
  41.  kill -9 $pid       
  42.  fi
  43. fi
  44. shift; shift; shift; shift; shift; shift; shift
  45. if [ $# -lt 7 ]   
  46. then
  47.  exit 0
  48. fi
  49. done
  50.  
  51. # EOF
  52.  
  53.