定时发送邮件

2018-08-03  本文已影响60人  watson168

描述:每五天发送一封邮件
1.写定时脚本
2.发送邮件
1.定时脚本

#!/bin/bash
last_run_time='1533212401'
dat=`date +%s`
last_new=`date -d '10 minutes ago' +%s`
five_days_secs=`echo "4*24*3600" | bc`
Today=`date`
if [[ $((dat - last_run_time)) -lt "${five_days_secs}" ]]; then
    echo "现在是 $Today            Today is a beautiful day" >> /var/log/send-email.log
   /usr/bin/python /home/ansible/wz-temp/remind/send-email.py wz@qq.com   Important  "现在是 $Today            Today is a beautiful day"
   
else
   sed -i "2c last_run_time='$last_new'" date.sh
    echo "现在是 $Today           Come on boy, you should do     an important thing today"  >> /var/log/send-email.log
   /usr/bin/python /home/ansible/wz-temp/remind/send-email.py  wz@qq.com  Important  " 现在是 $Today           Come on boy, you should do an important thing today"   
fi

2。1中发邮件脚本见https://www.jianshu.com/p/91c4668b546d

上一篇下一篇

猜你喜欢

热点阅读