/usr/share/doc/sac/examples/check is in sac 1.9b5-3.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | #!/bin/sh
#
# Check checks to see if any of the people who are logged in at the time
# have used up their allotment of time (as specified by MAXHOURS) on the
# modems (as specified by TTYS).
#
MAXHOURS=4.25
#TTYS="tty[C-F]*"
TTYS="tty[1-6] ttyp[0-4]"
hours=`date +%H:%M:%S`
users=`users`
u=`for x in $users; do echo $x; done | sort | uniq`
sac -pb $hours $u -T $TTYS | while read user time
do
res=`echo "$time <= $MAXHOURS" | bc`
if [ $res -eq 1 ]; then
echo "$user is OK. ($time)"
else
echo "$user is over the limit. ($time)"
fi
done
# If you use Sac to implement usage limits, the above can be modified to
# "logout" the user by modifing the above if statement to the below:
#
# if [ `expr $h '<=' $MAXHOURS` -eq 0 ]; then
# echo "You're over the time limit bozo! ($h) Bye Bye!" | write $user
# ps aux | tail +2 | while read usr PID whatever
# do
# if [ $usr = $user ]; then kill -9 $PID; fi
# done
# fi
#
# Running this script every 5-10 minutes in a cron job wouldn't be a bad idea
# either.
|