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