Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Log Off Dormant Users 4

Status
Not open for further replies.

glk

Technical User
May 21, 2002
1
US
Does anyone know of a script to log off dormant users?
 
You don't need a script, add -
set autologout=30 to /etc/csh.login (30 Minutes)
and
TMOUT=1800 to /etc/profile (1800 seconds = 30 Minutes)

Anyone remaining inactive for 30 minutes is automatically logged out.

Steve
 
glk
I was thinking of doing what you want to and kill them off, after carrying out the following and letting users no their idle time we soon educated them..


#!/bin/sh
#Program name:idleuser.sh
#Date created:March 2002

# Script to monitor system usage and idle time of users. #All users 45 minutes plus idle will be logged, any one #idle for 1 hour plus and depot managers and IT will #recieve an email

#Declare Variables
set -x
FATALMAIL="manager@myfirm.com, itdept@myfirm.com"
TODAY=`date +"%d/%m/%y at %T"`
LOGFILE=/u/shared/logs/usersidle.log
DEPOT=`uname -n`


echo "Report run on $TODAY.">> $LOGFILE

#filter users for selected conditions
finger -i | awk '/hour/ && $7 > 0 { print $1 ; }' > /dev/null 2>&1
if [ $? != 0 ]
then
finger -i | awk '/minutes/ && $7 > 45 { print $1 ; }' > /dev/null 2>&1
if [ $? != 0 ]
then
echo "There were no users with idle time in excess of 45 minutes
***-----------------------------------------------------***" >> $LOGFILE
fi
else
echo "The following users have been found idle:
User Idle time Process
----- --------- ---------------" >> $LOGFILE

#Log all 45+ minutes idle
finger -i | awk '/minutes/ && $7 > 45 { print $1 ; }' | while read USERS
do
w -h $USERS | awk '! /root/ {printf ("%-32s %-14s %-32s\n", $1,$4,$7); }' >> $LOGFILE
done


#Email raised warning of excessive idle time.
finger -i | awk '/hour/ && $7 > 0 { print $1 ; }' | while read USERS
do
w -h $USERS | awk '! /root/ {printf ("%-32s %-14s %-32s\n", $1,$4,$7); }' >> $LOGFILE
mail -s &quot;User Idle Problem&quot; $FATALMAIL <<-END
$USERS has been idle for 1 hr plus on $DEPOT.
Please note that future users with excessive idle time will
have their accounts locked.
END

done
fi
exit


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top