#!/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慢日志按天分割脚本
文章地址:
http://cdxtjz.com/article/iegoep.html