The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



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

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 11-27-2006
pbonilla pbonilla is offline
Registered User
  
 

Join Date: Aug 2002
Location: arizona
Posts: 11
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
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 10:06 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0