Summary: Last login older then 90 days

From: Himanshu Khona <himanshu.khona_at_patni.com>
Date: Wed Dec 24 2003 - 00:19:09 EST
Hey all,

Just to summarize a script to find users not logged in for more then last 3
months.

#A for loop on logins of users with username as input
for i in `logins -u| awk '{print $1}'` ;
do
{
## From the last command find the last month of user login & convert the
month string into corresponding number
lastmth=`last -n 1 $i|grep -v wtmp|sed '/^$/d'|sed 's/Dec/12/'|sed
's/Nov/11/'|sed 's/Oct/10/'|sed 's/Sep/9/'|s
ed 's/Aug/8/'|sed 's/Jul/7/'|sed 's/Jun/6/'|sed 's/May/5/'|sed
's/Apr/4/'|sed 's/Mar/3/'|sed 's/Feb/2/'|sed 's/
Jan/1/'|awk '{print $5}'`
A variable for current month
currmth=`date +%m`
#IF the last month value is non-null
if [ $lastmth ]
then
{
## If the difference is greater then 3 months echo that username or to
disable the login run passwd -l on $i
echo $currmth $lastmth
diff=`expr $currmth - $lastmth`
echo $diff
if [ $diff -gt 3 ]
then
echo $i
else
echo "$i is new"
fi
}
fi

} ;
done

Hope this helps.
If any of you find better ideas let everyone know.
I think this can be still improved..


Thanks,
Himanshu

PS: The shristmas out of office reflected on my mail box :-)
-----Original Message-----
From: sunmanagers-bounces@sunmanagers.org
[mailto:sunmanagers-bounces@sunmanagers.org]On Behalf Of Himanshu Khona
Sent: Wednesday, December 24, 2003 9:03 AM
To: sunmanagers@sunmanagers.org
Subject: Last login older then 90 days


Hi all,

Any ideas on getting users last logged in before 90 days??

Regards
Himanshu
_______________________________________________
sunmanagers mailing list
sunmanagers@sunmanagers.org
http://www.sunmanagers.org/mailman/listinfo/sunmanagers
_______________________________________________
sunmanagers mailing list
sunmanagers@sunmanagers.org
http://www.sunmanagers.org/mailman/listinfo/sunmanagers
Received on Wed Dec 24 00:21:07 2003

This archive was generated by hypermail 2.1.8 : Thu Mar 03 2016 - 06:43:25 EST