logrotate log management tool

logrotate is a log file management tool. For the old file rotation, compression, removal, and create a new log file. We can dump depending on the size of the log file, the number of days for easy log file management, usually by cron scheduled task to complete. 1. Configuration Examples
/var/log/messages {
    rotate 5
    weekly
    postrotate
        /sbin/killall -HUP syslogd
    endscript
}

"/var/log/httpd/access.log" /var/log/httpd/error.log {
    rotate 5
    mail [email protected]
    size 100k
    sharedscripts
    postrotate
        /sbin/killall -HUP httpd
    endscript
}

/var/log/news/* {
    monthly
    rotate 2
    olddir /var/log/news/old
    missingok
    postrotate
        kill -HUP ‘cat /var/run/inn.pid‘
    endscript
    nocompress
}
2. Configuration Options Description compress: by gzip compressed dump the old log nocompress: No compression, use this parameter copytruncate: still open for the log file, the current log backup and truncation nocopytruncate: backup log file but does not truncated create mode owner group: create a new log file using the specified file nocreate mode: create a new log file delaycompress: when used together and compress the dump next to the log file when the dump compression nodelaycompress: covered delaycompress options , while compressing the dump. errors address: Send error message to a designated storage spot Email address ifempty: even the empty dump files, this is the default option of logrotate. notifempty: If the file is empty, then no dump mail address: send a log dump file to a specified E-mail address nomail: log file does not send a dump olddir directory: dumped into the log file after the specified directory, and the current log file must be in the same file system noolddir: after the dump log file and the current log files in the prerotate / endscript the same directory: the command to be executed before the dump can put this right, both keywords must be on a separate line postrotate / endscript: after the dump command to be executed can put this right, the two keywords must sharedscripts trip alone: ​​all log files rotation after completion of the uniform implementation of a script daily: Specifies the turn storage period is weekly day: dump designated period of monthly per week: Specifies the dump cycle per month rotate count: Specifies the number of log files are deleted before the dump, 0 means no backup, backup 5 refers to retain the 5 size size: when when the log file reaches the specified size of the dump, size can be specified bytes (the default) and KB (sizek) or MB 3. Command Parameter Description # logrotate --help
Usage: logrotate [OPTION...] <configfile>
  -d, --debug               调试模式,输出调试结果,并不执行。隐式-v参数
  -f, --force               强制模式,对所有相关文件进行rotate
  -m, --mail=command        发送邮件 (instead of `/bin/mail')
  -s, --state=statefile     状态文件,对于运行在不同用户情况下有用
  -v, --verbose             显示debug信息
For reprint please indicate the source: http: //www.ttlsa.com/html/3169.html

Reproduced in: https: //my.oschina.net/766/blog/211014

Guess you like

Origin blog.csdn.net/weixin_33813128/article/details/91546374