Password expiry report


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Password expiry report
# 1  
Old 06-05-2012
Password expiry report

Hi All,
I want to write a script that will send the alert when linux server password expiry for user 'x' is less than 12 days.
I have written the below script but this is not working for expiry date 04 july

script;-

Code:
P_EXPIRY_DATE=`chage -l msdp| grep 'Password expires'   | awk ' { print $5 }' | cut -c1,2`
T_DATE=`date '+%e'`
P_EXPIRY_DAYS_LEFT=`expr $P_EXPIRY_DATE - $T_DATE`
if 
then
condition
else 
condition
fi


Any help will be really appreciated !!!!!!!

Last edited by Scrutinizer; 06-05-2012 at 08:13 AM.. Reason: code tags
# 2  
Old 06-06-2012
# 3  
Old 06-07-2012
How about this:

Code:
EXP=$(chage -l msdp | awk -F: '/Password expires/{ print $2}')
if [[ $EXP =  *never ]]
then
    EXP_DAYS=9999
else
    NOW_SEC=$(date +%s)
    EXP_SEC=$(date -d "$EXP" +%s)
    EXP_DAYS=$((( EXP_SEC - NOW_SEC ) / 3600 / 24))
fi
if [ $EXP_DAYS -lt 12 ]
then
   echo "Will expire in $EXP_DAYS days"
else
   echo "Still a while to go yet"
fi

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Need a script to set non-expiry password

Hi All, I have a gateway server, from where I can connect any server via 'sudo ssh server_name'. Generally, if we need to run a command on any number of servers, we put server names in a file like '/tmp/ser_name' and execute it with for loop from gateway server. Now, I need to set non-expiry... (0 Replies)
Discussion started by: solaris_1977
0 Replies

2. Solaris

disable password expiry

Hi How do i disable password expiration on ldap? It runs on Solaris 10 machine. Thanks in advance. (3 Replies)
Discussion started by: hrist
3 Replies

3. Solaris

Password Expiry Promtps Not Visable

Hi all. On our systems we use the password expiry through the shadow file. This was recently implemented and the first round of expiry has just arrived. The problem that i have is that when users are attempting to log on to a box (directory through putty) there are no prompts displayed if... (13 Replies)
Discussion started by: boneyard
13 Replies

4. Shell Programming and Scripting

password expiry notification

Hi, Could someone please let me know how to write script for passwd expiry notification on salaries boxes. Regards Dnyan (1 Reply)
Discussion started by: dnyan
1 Replies

5. SuSE

Disable the password expiry date

Hi, We are going to create the new user, using that user we are automate the work, but every 90 days password get expired how can i create or avoid the expiry the password. (1 Reply)
Discussion started by: kingganesh04
1 Replies

6. Solaris

SSH Password-less login fails on password expiry.

Hi Gurus I have a few Sol 5.9 servers and i have enabled password less authentication between them for my user ID. Often i have found that when my password has expired,the login fails. Resetting my password reenables the keys. Do i need to do something to avoid this scenario or is this... (2 Replies)
Discussion started by: Renjesh
2 Replies

7. Solaris

Notification of password expiry.

Hi, Is there any way of sending an email to a number of users indicating that the passwords of user accounts will expire? Currently we have a test server with a number of oracle test accounts on it. Each of these accounts correspond to an instance of Oracle on the server. These... (2 Replies)
Discussion started by: sparcman
2 Replies

8. Solaris

Notification of password expiry.

Hi, Is there any way of sending an email to a number of users indicating that the passwords of user accounts will expire? Currently we have a test server with a number of oracle test accounts on it. Each of these accounts correspond to an instance of Oracle on the server. These... (2 Replies)
Discussion started by: sparcman
2 Replies

9. AIX

How to check password expiry in AIX?

Hi All, Could anyone please help me with the command or script for checking the password expiry for a particular userid on AIX. Regards, Sanjay...:) (5 Replies)
Discussion started by: SanjayPasum
5 Replies

10. UNIX for Advanced & Expert Users

password expiry

Hi, under SUN Unix, in which file the expiry date of a user password is indicated ? Many thanks. (2 Replies)
Discussion started by: big123456
2 Replies
Login or Register to Ask a Question