用脚本检测出所有用户密码还有多长时间过期,小于10天,则警告用户需要修改密码!
bin/bash
[ ! $USER=root ] && echo "only root can execute this script && exit
MYFILE='/etc/shadow'
let TODAY=$[ `date +"%s"` /24/60/60 ]
if [ -e $MYFILE ];then
while read LINE;do
NAME=`echo $LINE |cut -d: -f1`
let MAX=`echo $LINE | cut -d: -f5`
[ $[$MAX-TODAY] -le 10 ] && echo "${NAME}'s passwd need change"
done<$MYFILE
fi
本文转自 张玉坡 51CTO博客,原文链接:http://blog.51cto.com/fighter/466397