码迷,mamicode.com
首页 > 其他好文 > 详细

AIX检测用户密码过期

时间:2014-09-05 16:26:02      阅读:570      评论:0      收藏:0      [点我收藏+]

标签:ksh   shell   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=$(($EXPIREDTIME-$DAYNUMA))
                if     [ $DAYVALUE -lt 30 ]&&[ $DAYVALUE -gt 0 ]
                        then    echo "$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检测用户密码过期

标签:ksh   shell   aix   

原文地址:http://xin23.blog.51cto.com/1827266/1549232

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!