Script to calculate user's last login to check if > 90 days

I need a script to figure out if a user's last login was 90 days or older. OS=AIX 5.3, shell=Korn
Here's what I have so far:

#!/usr/bin/ksh
NOW=`lsuser -a time_last_login root | awk -F= '{ print $2 }'`
(( LAST_LOGIN_TIME = 0 ))
(( DIFF = $NOW - $LAST_LOGIN_TIME ))
lsuser -a time_last_login ALL |\
while read LAST_LOGIN_RECORD
do
(( DIFF = NOW - LAST_LOGIN_TIME ))
if [[ $LAST_LOGIN_TIME <= 0 ]]; then
echo "LAST_LOGIN_TIME <= 0"
else
echo "FOUND! LAST_LOGIN_TIME > 0"
fi
done

====
Thanks in advance!

> last | grep xxx | head -1
xxx   sshd         10-1-111-111-bos Thu Oct 30 11:12 - 11:12  (00:00)
> 

That told me my last login was yesterday at 11:12 am
So, if that gets you started, then review date calculations.
See the following:
http://www.unix.com/unix-dummies-questions-answers/4870-days-elapsed-between-2-dates.html\#post16559

For AIX you might want to try lssec:
lssec -f /etc/security/lastlog -s root -a time_last_login

You will have to convert it to a readable date.

Hi all, I couldn't help thinking that using that Perderabo script You linked to is way over the top for a simple problem like determining wheher 90-days has passed or not. Actually for any dates after 1970, one should use the date program. One way is to express the date in seconds since 1970-01-01 00:00:00 UTC.

echo $((($(date +%s)-$(date +%s -d 2001-10-21))/86400))

This is eqivalent to "Todays date expressed in seconds, minus the older date, expressed in seconds, and divide the difference by 86400, the number of seconds per day," resulting in the difference in days between the dates. This vaild for any dates after 1970-01-01 up until, well, raher a way up in the future. The date string must for simplicity be expressed in Your current LOCALE.

Now handling dates before 1970, that is a different story!

/Lakris