跳转到内容

LogRotate

1 post with the tag “LogRotate”

LogRotate

LogRotate is a log manage tool, which enables log files’ cutting, deleting and creating, and triggered by crontab.

The default config file located /etc/logrotate.conf

In default config file, the config folder /etc/logrotate.d is included by default. Which means, config files added in this folder will be executed by logrotate process.

/var/log/***.log { # The target log file
LOG_CONFIG_PARAMETERS # The parameters for logrotate
}
  • daily: 切割周期为 每天
  • weekly: 切割周期为 每周
  • monthly: 切割周期为 每月
  • yearly: 切割周期为 每年
  • size 50M
  • rotate 1
  • maxage 1
  • tabooext [+] list
  • missingok
  • copytruncate/nocopytruncate
  • create mode owner group
  • nocreate
  • nocompress
  • compress
  • delaycompress
  • nodelaycompress

(11). 在所有其它指令完成前执行

Section titled “(11). 在所有其它指令完成前执行”
  • prerotate
  • endscript

(12). 在所有其它指令完成后执行

Section titled “(12). 在所有其它指令完成后执行”
  • postrotate
  • endscript
  • sharedscripts

(14). 错误信息发送到指定的Email地址

Section titled “(14). 错误信息发送到指定的Email地址”
  • errors address

(15). 转储的日志文件发送到指定的E-mail地址

Section titled “(15). 转储的日志文件发送到指定的E-mail地址”
  • mail address
  • nomail
  • ifempty
  • notifempty
  • olddir directory
  • noolddir
  • dateext
  • dateformat
  • dateyesterday
  • extension

[1]. https://blog.csdn.net/xiaojin21cen/article/details/122309230

[2]. https://linux.die.net/man/8/logrotate