首页 > 代码库 > 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检测用户密码过期
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。