`
Fangrn
  • 浏览: 799104 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

check 系统账号密码是否过期shell脚本

阅读更多

自己写的check aix系统用户密码是否过期的shell 脚本,单位环境是设置用户密码3个月过期,时间长了经常有账户密码过期。供大家参考。

# Check user password expired
currenttime=`perl -le "print scalar time" `
maxage=`grep -p default: /etc/security/user | awk '$1 ~ /maxage/ {print $3}'`
expiretime=`expr $maxage \* 604800`
userlist=`cat /etc/passwd |awk -F ":" '{ print $1 }'`
count=0

for i in $userlist ; do
  grep -p ^${i}: /etc/security/passwd | awk '$1 ~ /lastupdate/ {print $3}' | read lastupdate &&
  threshold=`expr $currenttime - $lastupdate`
  if [ $threshold -gt $expiretime ]  
  then
  count=`expr $count + 1`
  echo "${i}"
  fi
done
  
if [ $count -eq 0 ]
then
echo "None"
fi
 
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics