03-07-2012 09:17 PM
What type of passwords so you have? Standard, trusted, enhanced?
With standard, you can use logins: -x -l user1,user2
Unfortunately the result is a DDMMYY last password changed value and a number of days until it expires.
03-07-2012 09:40 PM
please find the below output
unix1$logins -x -l rajesh
rajesh 113 admin 105
PS 030812 0 182 7
we required password expire for trusted system
03-07-2012 10:55 PM
please find below is my requirment
i need to set a alert mail , whenever password expire time reach, sent mail to perticular user automatiicaly
03-08-2012 01:27 AM
>PS 030812 0 182 7
This says the password was reset today (Mar 8) and will expire in 182 days, 26 weeks or about 6 months.
>whenever password expire time reach
You search the forum for similar requests. Otherwise you need to do date arithmetic on the above date and duration. perl will work wonders here.
03-08-2012 03:50 AM
> what is the meaning for expwarn
If expwarn is set to "-1", it means "use the system-wide expwarn value". The output of the "logins" command reveals that the system-wide expwarn value in your system is 7 days.
If expwarn is set to any other non-zero value, it means the time (in days) the system warns the user at login time when the password is about to expire.
For example, if the user's password would expire on 14 March and expwarn is set to 14, on 1 March and after that the user will see the message "Your password will expire in NN days." when s/he logs in, until s/he changes the password or the password actually expires.
> PS 030812 0 182 7
The script would need to convert the MMDDYY date 030812 to an Unix timestamp, add 15724800 seconds to the timestamp value ( password max age: 182 days * 24 hours/day * 60 minutes/hour * 60 seconds/minute = 15724800 seconds), subtract the desired warning time, and compare the result to the current Unix timestamp.
The result would be the timestamp when the script should start warning the user: if it is greater than the current timestamp, there is no need to warn that user yet. If the result is less than the current timestamp, the warning should be sent.
If you want to generate a human-readable password expiration date, just convert the password setting date to Unix timestamp and add the password max age to it as above, and convert the result to a human-readable date.
This should be be an easy task for anyone who can write Perl scripts, as Perl has built-in functions for converting human-readable dates to Unix timestamps and vice versa.