MySQL慢日志切割邮件发送脚本

#!/bin/bash
time=`date -d yesterday +"%Y-%m-%d"`
slowlog='/usr/local/percona/data/slow.log'
#提前创建好一个存放目录:/usr/local/percona/slow_log

cut_slowlog='/usr/local/percona/slow_log'
mv $slowlog $cut_slowlog/slow-$time.log
/usr/local/percona/bin/mysql  -S /usr/local/percona/data/mysql.sock  -e "flush slow logs;"

mail  -s 'slow log'  abc@qq.com  < $cut_slowlog/slow-$time.log

posted @ 2018-12-05 12:38  Manger  阅读(285)  评论(0编辑  收藏  举报