- 论坛徽章:
- 33
|
Demo_Password.sh- #!/bin/bash
- threshold=5
- username=root
- passinfo=`/bin/grep "^${username}" /etc/shadow`
- lastchange=`echo "${username}" | /bin/awk -F: '/root/{print $3}'`
- max=`/bin/awk -F: '/root/{print $5}' /etc/shadow`
- today=`/usr/bin/perl -e 'printf "%5d\n", time()/3600/24'`
- let countdown=${lastchange}+${max}-${today}
- if [ "${countdown}" -le "${threshold}" ]; then
- echo "${countdown}" -le "${threshold}"
- echo "Password of ${username} will expire in $countdown days" | /bin/mailx -r "monitor@monitor.com" -s "Alert" "receiver@receiver.com"
- else
- echo "${countdown}" -gt "${threshold}"
- fi
复制代码 |
|