對比時間發郵件

#!/bin/bash
rm -f /tmp/date.txt
mysql -uroot -paike100*  -e  "select created_at from qianqu.discovers order by created_at desc limit 1 into outfile '/tmp/date.txt'"
date1=`cat /tmp/date.txt`
date2=`date +"%Y-%m-%d %H:%M:%S"`
dbtime=`date -d "$date1" +%s`
systime=`date -d "$date2" +%s`
time=`expr $systime - $dbtime`
if [ $time -gt 7200 ]; then
echo -e "Interval:$timeS \n" "dbtime=$date1 \n"  "servertime=$date2" |mail -s "qiandberror_$date2" [email protected] [email protected]
fi

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章