curl -s https://example.com > current.html
if diff -q previous.html current.html > /dev/null; then
echo "No changes!"
else
echo "Changes detected! URL: https://example.com" | mail -s "报告!有更新!" "我的邮箱@qq.com"
mv current.html previous.html
fi
mail配置
vim /etc/mail.rc
在最后添加
set from=xx@qq.com
set smtp=smtp://smtp.qq.com
set smtp-auth-user=xx@qq.com
set smtp-auth-password=邮箱授权码
set smtp-auth=login
#如果不行,打开服务器25端口试试
mail问题!
在使用mail把一个文本文件中的内容作为邮件内容发送后,出现了收到邮件为二进制附件的问题!
原因:
使用了xshell的xftp中的使用记事本编辑
——这会使发送的文档为dos格式!
当使用了
dos2unix xxx.txt
mail -s "标题" 邮箱@qq.com < xxx.txt
再次发送将会正常!