首页 > 代码库 > AIX检测用户密码过期

AIX检测用户密码过期



#    帮朋友写的,时间比较仓促,仅做了初步的测试,既然写了就贴出来分享下,供交流学习使用.



#!/usr/bin/ksh
# AUTHOR:               Xin23
# Version:  Beta 0.1 
# Date:     2014-09-05

Get_Days_From_1970(){

BEGINYEAR=1970
ENDYEAR=$(date +%Y)
YEARNUM=$(($ENDYEAR-$BEGINYEAR))
LYEARNUM=$(($YEARNUM/4))
RNUM=${LYEARNUM%.*}
DAYNUMY=$(($YEARNUM*365))
DAYNUMZ=$(($DAYNUMY+$RNUM))
DAYNUMA=$(($(date +%j)+$DAYNUMZ))

}

Get_Days_From_1970

for USER in $(grep ksh /etc/passwd| cut -f 1 -d ‘:‘)
do
     LASTUPDATETIMESECOND=$(grep -p $USER /etc/security/passwd | grep lastup | awk ‘{print $3}‘) 
     if [ -z "$LASTUPDATETIMESECOND" ]
        then    continue
        else    LASTUPDATETIME=$(expr $LASTUPDATETIMESECOND / 86400 )
                EXPIREDTIME=$(($LASTUPDATETIME+140))
                DAYVALUE=http://www.mamicode.com/$(($EXPIREDTIME-$DAYNUMA))"$USER Should Change Password !!!"
                elif [ $DAYVALUE -lt 30 ]&&[ $DAYVALUE -lt 0 ]
                        then    echo "$USER Already Expired !!!"
                fi
     fi
done



执行如下:


[aybq76:root]#./AIX_Check_Password.sh

root Should Change Password !!!

mqm Already Expired !!!

monitor Should Change Password !!!

app_r01 Already Expired !!!

ora_r01 Already Expired !!!

app_prd2 Already Expired !!!

ora_prd2 Already Expired !!!

app_prd3 Already Expired !!!



The End


本文出自 “Xin23的流水账” 博客,谢绝转载!

AIX检测用户密码过期