Skip to content

LogRotate

1 post with the tag “LogRotate”

LogRotate

LogRotate is a log management 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.dis 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: The cutting cycle is daily
  • weekly: The cutting cycle is weekly
  • monthly: The cutting cycle is monthly
  • yearly: The cutting cycle is every year
  • size 50M
  • rotate 1
  • maxage 1

(5). Do not dump files with specified extensions

Section titled “(5). Do not dump files with specified extensions”
  • tabooext [+] list
  • missingok
  • copytruncate/nocopytruncate
  • create mode owner group
  • nocreate
  • nocompress
  • compress
  • delaycompress
  • nodelaycompress

(11). Execute before all other instructions are completed

Section titled “(11). Execute before all other instructions are completed”
  • prerotate
  • endscript

(12). Execute after all other instructions are completed

Section titled “(12). Execute after all other instructions are completed”
  • postrotate
  • endscript
  • sharedscripts

(14). The error message is sent to the specified email address

Section titled “(14). The error message is sent to the specified email address”
  • errors address

(15). Send the dumped log file to the specified E-mail address

Section titled “(15). Send the dumped log file to the specified E-mail address”
  • 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