soyizi 发表于 2018-10-10 11:38:15

mysql的logrotate脚本

# This logname can be set in /etc/my.cnf  
# by setting the variable "err-log"
  
# in the section as follows:
  
#
  
#
  
# err-log=/usr/local/mysql/data/mysqld.log
  
#
  
# If the root user has a password you have to create a
  
# /root/.my.cnf configuration file with the following
  
# content:
  
#
  
#
  
# password =
  
# user= root
  
#
  
# where "" is the password.
  
#
  
# ATTENTION: This /root/.my.cnf should be readable ONLY
  
# for root !
  

  
#这里日志文件为datadir下的*.log和*.err文件
  
/data/mysqldata/*.log /data/mysqldata/*.err {
  
      create 600 mysql mysql
  
      notifempty#如果日志为空logrotate不会进行
  
       daily
  
      rotate 3
  
      missingok#日志logrotate期间任何错误都忽略
  
      compress
  
    postrotate#在logrotate之前要判断mysql是否启动,如果没有启动就flush-logs
  
       # just if mysqld is really running
  
       if test -x/usr/local/mysql/bin/mysqladmin && \
  
          /usr/local/mysql/bin/mysqladmin ping &>/dev/null
  
       then
  
          /usr/local/mysql/bin/mysqladmin flush-logs
  
       fi
  
    endscript
  
}
  
# cp mysql-log-rotate /etc/logrotate.d/mysqld


页: [1]
查看完整版本: mysql的logrotate脚本