首页 > 数据库 > 文库 > 正文

slow慢日志按天分割脚本

2022-07-28 22:41:04
字体:
来源:转载
供稿:网友
       #!/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 {} /;

(编辑:错新网)

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表

图片精选