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