Sponsored Content
Top Forums UNIX for Advanced & Expert Users Password Expiration Notification Post 302458248 by Kesavan on Thursday 30th of September 2010 08:07:36 AM
Old 09-30-2010
MySQL Password Expiration Notification

i think this script will help you...

Code:
#!/usr/bin/ksh
function juliandate {
day=$1
month=$2
year=$3
 ((standard_jd = day - 32075 + 1461 * (year + 4800 - (14 - month)/12)/4 + 367 * (month - 2 + (14 - month)/12*12)/12 - 3 * ((year + 4900 - (14 - month)/12)/100)/4))
 ((jd = standard_jd-2400001))
return $jd
}
######
#MAIN#
######
userid=$USER
 if [ "$userid" = "root" ]
 then
   awk -F ":" '{print $1}' /etc/shadow  > userlist.txt
   while read User
   do
     chage -l $User > userdetail.txt
     Password_Expiry_Date=`awk '/Password Expires/' userdetail.txt | awk -F ":" '{print $2}'`
     Warning_days=`awk '/Warning/' userdetail.txt | awk -F ":" '{print $2}'`
     P_Expiry_Date=$(date -d "$Password_Expiry_Date" +%Y-%m-%d)
     Expiry_Date=`echo $P_Expiry_Date | awk -F "-" '{print $3}'`
     Expiry_Month=`echo $P_Expiry_Date | awk -F "-" '{print $2}'`
     Expiry_Year=`echo $P_Expiry_Date | awk -F "-" '{print $1}'`
     Today=$(date -d "`date`" +%Y-%m-%d)
     Date=`echo $Today| awk -F "-" '{print $3}'`
     Month=`echo $Today | awk -F "-" '{print $2}'`
     Year=`echo $Today | awk -F "-" '{print $1}'`
     juliandate $Date $Month $Year
     julianday1=$?
     juliandate $Expiry_Date $Expiry_Month $Expiry_Year
     julianday2=$?
     diff_days=`expr $julianday2 - $julianday1`
     if [ $diff_days -le $Warning_days ]
     then
       if [ $diff_days -eq 0 ]
       then
         mailx -s "RENEW PASSWORD TODAY ITSELF" $User@mail.com  < message1.txt
       elif [ $diff_days -lt 0 ]
       then
          mailx -s "Your Password Expired" $User@mail.com < message2.txt
       else
          echo "Your password is going to expire in $diff_days day(s)" > message3.txt
          mailx -s "Renew Password" $User@mail.com < message3.txt
         fi
     fi
   done < userlist.txt
 else
   echo "You need root permission to run this script"
 fi

Smilie

remove the "mail.com" and put your mail domain name there.....
you can set this script as a cron job in the server's and it will send mail's accordingly to the user's by verifying their password expiration date.
Edit the message according to your desire. if you placing the message in other directories, don't forget to mention the path..

Last edited by Kesavan; 10-04-2010 at 09:50 AM..
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Password expiration warning.

Hi, Anyone know the command which identifies how long a user has before their password expires? I also need to know how I would write and expr to calculate the difference between 2 dates. e.g. 28/03/05 - 18/03/05 = 10 I was told there is a date function which shows you no of days since... (1 Reply)
Discussion started by: sureshy
1 Replies

2. HP-UX

UNIX ID Password Expiration

We are trying to implement an Password Aging system that will force UNIX Accounts to change their passwords every 3 mons or so. This will be done my our Server Support Provider. We want to identify UNIX IDs that connects to our server via ftp,scp,sftp and other special connection protocols. IN... (2 Replies)
Discussion started by: tads98
2 Replies

3. Solaris

password expiration

Hello can anyone explain where can be found logic for user password expiration on solaris as well as on reliant UNIX?? there is not much help of /etc/security directory..does not exist! any help? (3 Replies)
Discussion started by: abdulaziz
3 Replies

4. Linux

password expiration ?!?

Hi All, I have this user on my /etc/shadow: mysql:$1$vmw4r078$4.lp6z2s0KJYHKXTuPG2x0:13556:0::12::: The 5 column is blank. Does it mean the user has no password expiration. Thanks in advance for any idea. (1 Reply)
Discussion started by: itik
1 Replies

5. Solaris

CDE password change on expiration

Hello, I am using Solaris 10 with CDE and like to change the behaviour of the login process. I have a user account that is configured for password aging. Currently, when his password expires, CDE prompts him to change his password when login in. What I'd like is that the user cannot... (5 Replies)
Discussion started by: gorfou
5 Replies

6. AIX

Mail for password expiration

Hi guys, A simple question. which mecanism send an email to an unix user for the expiration of his password? Thank you! (4 Replies)
Discussion started by: Chapel
4 Replies

7. AIX

Password expiration

Hi Admins, AIX 5.3 I know maxage value tells the system about password expiration policy. One of the user's maxage is 5 weeks.But he changed the password long backup at 2008 according to lastupdate value. Since maxage is 5, the password should expire every 5 weeks.But how come... (4 Replies)
Discussion started by: newaix
4 Replies

8. Ubuntu

Password Expiration Policy

Hello Team, I am using Lubuntu & have DRBL remote boot setup with open Ldap authentication. Currently there is no password expire policy. I want to set Password Policy so that user's password will expire after a month & they will get prompt to change their password. Using PAM we can do it,... (1 Reply)
Discussion started by: paragnehete
1 Replies

9. UNIX and Linux Applications

User account expiration notification

Dear Concern, Is there any built in tool/application/command available for Linux user account expiration notification purpose. With Best Regards, Md. Abdullah-Al Kauser (2 Replies)
Discussion started by: makauser
2 Replies

10. Shell Programming and Scripting

Password expiration notification

Dear Concern, I want to write a shell script in linux for mail notification of users whose password is about to expire within 7 days or already has expired. Is there any alternative way except to check the "date" command output and compare it with "chage -l username" command output. Please... (1 Reply)
Discussion started by: makauser
1 Replies
IGAWK(1)							 Utility Commands							  IGAWK(1)

NAME
igawk - gawk with include files SYNOPSIS
igawk [ all gawk options ] -f program-file [ -- ] file ... igawk [ all gawk options ] [ -- ] program-text file ... DESCRIPTION
Igawk is a simple shell script that adds the ability to have ``include files'' to gawk(1). AWK programs for igawk are the same as for gawk, except that, in addition, you may have lines like @include getopt.awk in your program to include the file getopt.awk from either the current directory or one of the other directories in the search path. OPTIONS
See gawk(1) for a full description of the AWK language and the options that gawk supports. EXAMPLES
cat << EOF > test.awk @include getopt.awk BEGIN { while (getopt(ARGC, ARGV, "am:q") != -1) ... } EOF igawk -f test.awk SEE ALSO
gawk(1) Effective AWK Programming, Edition 1.0, published by the Free Software Foundation, 1995. AUTHOR
Arnold Robbins (arnold@skeeve.com). Free Software Foundation Nov 3 1999 IGAWK(1)
All times are GMT -4. The time now is 06:55 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy