Finding the date x number of days ago in the shell
Dave | July 8, 2009If you need to find what the date was X number of days ago in AIX ( 5.3 or greater ), or Linux :-
First convert the number of days to hours e.g. if you want to find the date 90 days ago you need 90 * 24 = 2160
echo `TZ=GMT+2160 date +%d/%m/%y`
You can of course use any of the % formats to get the output you require.
To compare two dates ( very useful in AIX to see if a user has not logged in for 90 days for example ) use the %s to get the number of seconds since 1st Jan 1970 :-
echo `TZ=GMT+2160 date +%s`
lsuser -a time_last_login username ( needs to run as root )
Then compare the two numbers and if the 90 days ago number is gretaer than the output of the lsuer command then that user has not logged in for gretaer than 90 days





