sql查询数据结果发送到邮箱
#!/bin/bash user=root password=xx dbname=xx DATE=`date +%F`
#注意:此处mysql要用全路劲,否则计划任务会执行失败 /mydata/mysql/bin/mysql -u$user -p$password << EOF use xx; SELECT service_id FROM xx WHERE DATE_FORMAT(createtime, "%Y-%m-%d") <> DATE_FORMAT(tracetime, "%Y-%m-%d") AND orderno = pos_orderno AND createtime>DATE_FORMAT(NOW(), "%Y-%m") into outfile '/opt/buchongzhi/buchongzhi.txt' EOF mail -s "补充值" xx@163.com,xx@163.com < /opt/buchongzhi/buchongzhi.txt sleep 10 mv /opt/buchongzhi/buchongzhi.txt /opt/buchongzhi/buchongzhi.txt_$DATE