![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| kill idle users | efrenba | HP-UX | 13 | 03-31-2008 10:38 PM |
| Killing idle users TIA | PapaBear | Shell Programming and Scripting | 2 | 01-14-2008 04:37 PM |
| HP-UX users get logged off while idle. | Laoinjo | UNIX for Advanced & Expert Users | 5 | 06-04-2007 11:28 AM |
| finding idle users | rfmurphy_6 | Shell Programming and Scripting | 3 | 07-06-2005 01:03 PM |
| Log off idle users | wtofu | AIX | 0 | 06-30-2005 09:38 PM |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
Idle users over 1 day
Please help, im modifing an idle script to capture (not kill) users who havee been idle over a time. now i've got to work with the exection of users whos idle time gove over 24 hrs and becomes "old". please advice on how to correct...
Code:
#Clear old report, generate new data and new report
echo "\n `date` \n" > /tmp/idle.report
clear
who -u > /tmp/idle.a
grep -v "\. " /tmp/idle.a > /tmp/idle.b
count=0;
while read a b c d e f g;
do
hrs=$(echo $f | awk -F: '{print $1}' )
name=$(grep $a /etc/passwd | awk -F: '{print $5}')
#Users logged in over 24 hours
if [ $hrs = `old` ] ; then
echo "UID $a \n USERNAME $name \n IDLE FOR OVER 24 HOURS \n ON PORT $b \n TOTAL TIME OVER 24 HOURS \n" >> /tmp/idle.report
let count=$count+1
else
#Hours allowed
if [ $hrs -gt 8] ; then
echo " UID $a \n USERNAME $name \n IDLE FOR $hrs HOURS \n ON PORT $b \n TOTAL TIME $f \n" >> /tmp/idle.report
let count=$count+1
fi
fi
done < /tmp/idle.b
echo "\n\n TOTAL USERS IN IDLE..:$count\n" >> /tmp/idle.report
# Only email report if there is 1 or more users that is on idle
if [ $count -gt 0 ] ; then
mailx -s "Idle report `date`" user@email.com < /tmp/idle.report
fi
|
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|