# 帮朋友写的,时间比较仓促,仅做了初步的测试,既然写了就贴出来分享下,供交流学习使用.
#!/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
时间: 2024-10-12 01:09:34