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
 

你可能感兴趣的:(脚本,Security,F#,perl,AIX)