linux定期自动更改密码并发送邮件的小脚本
#!/bin/bash
tr -dc _A-Z-a-z#$%^*-0-9 </dev/urandom |head -c20 >/home/1.txt
cat /home/1.txt |passwd root --stdin
SendStatus=`mail -v -s "test mail" rocdk890@163.com< /home/1.txt | grep -c "Sender ok" `
rm -rf /home/1.txt
if [ "$SendStatus" == "1" ] ; then
echo "Sender mail ok"
else
echo "Sender mail fail!"
sleep 50
sh /home/ceshi.sh
fi
tr -dc _A-Z-a-z#$%^*-0-9 </dev/urandom |head -c20 >/home/1.txt
cat /home/1.txt |passwd root --stdin
SendStatus=`mail -v -s "test mail" rocdk890@163.com< /home/1.txt | grep -c "Sender ok" `
rm -rf /home/1.txt
if [ "$SendStatus" == "1" ] ; then
echo "Sender mail ok"
else
echo "Sender mail fail!"
sleep 50
sh /home/ceshi.sh
fi
评论: