slow慢日志按天分割脚本

#!/bin/bash
####split MySQL slow-query-log#######
LOG=/u01/mysql/5310/log/slow
DATE=`date +"%Y-%m-%d"`
user=root
passwd=root01
#stop slow_query_log
mysql -u$user -p$passwd -e "set global slow_query_log=0"
#reset the filename of slow_query_log
mysql -u$user -p$passwd -e "set global slow_query_log_file='${LOG}/slow_query_${DATE}.log'"
#enable slow_query_log
mysql -u$user -p$passwd -e "set global slow_query_log=1"
#remove slow_query_log 7days ago.
cd $LOG
find ./slow_query* -ctime +7 -exec rm -f {} \;

文章题目:slow慢日志按天分割脚本
URL网址:http://ybzwz.com/article/iegoep.html