Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site investor.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!think!harvard!seismo!rochester!cmu-cs-pt!cadre!pitt!darth!investor!rbp From: rbp@investor.UUCP (Bob Peirce) Newsgroups: net.unix,net.unix-wizards Subject: Re: Idle time logout mechanism (daemon) Message-ID: <215@investor.UUCP> Date: Wed, 17-Jul-85 13:44:57 EDT Article-I.D.: investor.215 Posted: Wed Jul 17 13:44:57 1985 Date-Received: Sat, 20-Jul-85 02:44:47 EDT References: <250@ubvax.UUCP> Organization: Cookson, Peirce & Co., Pittsburgh, PA Lines: 98 Xref: watmath net.unix:5068 net.unix-wizards:13899 > Does anyone have (or know of) a daemon which will monitor users idle time, > and logout any user idle longer than a given amount of time. > Please respond via mail and as usual, I will summarize for the net. Sorry, I don't have a path to you, but this works on SYS III. I use it as part of my el-cheapo, one modem both ways set-up. Stick it in cron to run every once in a while. You may want to modify this to handle several lines. # -- ckmod # Robert B. Peirce; Cookson, Peirce & Co., Inc. # If anyone is inactive on a modem > $GRACE minutes log them off # This version gives no quarter. # Have to look for hung outgoing uucp stuff too. if [ $# -ne 1 ] then echo "usage: ckmod tty#" exit 1 fi MODEM=$1 GRACE=15 # minutes of no activity HM=/usr/lib/uucp LOG=/u/rbp/kill.log SPOOL=/usr/spool/uucp cd $HM # If set doesn't produce anything, force it. set `who | grep tty$MODEM || echo XXX` U=$1 if [ $U = XXX ] then U="" fi # Get current time set `date | tr ":" " "` M=$2 D=$3 HC=$4 MC=$5 # Get time device last accessed set `/usr/ucb/ls -l /dev/tty$MODEM | tr ":" " "` HL=$8 ML=$9 # Check for midnight crossover if [ $HL -gt $HC ] then HL=`expr $HL + 24` fi # Calculate time since last access of device TIME=`expr \( 60 "*" $HC + $MC \) - \( 60 "*" $HL + $ML \)` if [ $U ] then if [ $TIME -ge 1 ] then echo "$U tty$MODEM ($M $D $HC:$MC $HL:$ML) $TIME minutes.\c"\ >> $LOG if [ $TIME -lt $GRACE ] then echo >> $LOG fi fi if [ $TIME -ge $GRACE ] then # Let him have it P=`ps -ft$MODEM | awk 'BEGIN{FS=" "}/'$U'/{print $2;exit}'` if [ $P ] then kill -9 $P echo " Killed after $TIME minutes." >> $LOG else echo >> $LOG fi fi else # Nobody logged on from outside LCK=`ls $SPOOL | egrep "LCK\.\..|.lock"` # locks placed in uucp if [ "$LCK" -a $TIME -ge $GRACE ] # uucp has hung then cd $SPOOL rm -f $LCK fi fi -- Bob Peirce uucp: ...!{allegra, bellcore, cadre, idis} !pitt!darth!investor!rbp