2020 Feb. 10.
#!/bin/bash # get log of epg-data-receiving in these 24 hours in epgre_una and mail to user. OutFile="LOG/FILE.txt" MysqlPasswordFile="EPGREC/MYSQL/PASSWORD/FILE.txt" FromTime=`date -d yesterday "+%Y-%m-%d %H:%M:%S"` TillTime=`date -d today "+%Y-%m-%d %H:%M:%S"` MailTo=YOURMAIL@gmail.com MailTitle='epgrec_una_level1_error_in_24hours' if [ -f ${OutFile} ]; then rm ${OutFile} fi # select from epgrec_una_mysql read Password < ${MysqlPasswordFile} mysql -u MYSQL_EPGREC_UNA_USER -p${Password} EPGREC_UNA_DB -e "select * from Recorder_logTbl w here ( level = 1 OR message like '%EPG更新完了%') AND ( logtime BETWEEN '${From Time}' AND '${TillTime}' ) order by logtime desc" > ${OutFile} # mail cat ${OutFile} | mail -s `echo -e "${MailTitle}" | nkf -jM` ${MailTo} exit 0