LogRotate
0. Introduction
Section titled “0. Introduction”LogRotate is a log manage tool, which enables log files’ cutting, deleting and creating, and triggered by crontab.
1. Configuration Files and Path
Section titled “1. Configuration Files and Path”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.
2. Config demo
Section titled “2. Config demo”/var/log/***.log { # The target log file LOG_CONFIG_PARAMETERS # The parameters for logrotate}3. Supported Parameters
Section titled “3. Supported Parameters”(1). 切割周期
Section titled “(1). 切割周期”- daily: 切割周期为 每天
- weekly: 切割周期为 每周
- monthly: 切割周期为 每月
- yearly: 切割周期为 每年
(2). 转存大小
Section titled “(2). 转存大小”- size 50M
(3). 日志保存份数
Section titled “(3). 日志保存份数”- rotate 1
(4). 保留日志天数
Section titled “(4). 保留日志天数”- maxage 1
(5). 不转储指定扩展名的文件
Section titled “(5). 不转储指定扩展名的文件”- tabooext [+] list
(6). 忽略错误
Section titled “(6). 忽略错误”- missingok
(7). 备份/截断
Section titled “(7). 备份/截断”- copytruncate/nocopytruncate
(8). 创建权限
Section titled “(8). 创建权限”- create mode owner group
- nocreate
(9). 压缩
Section titled “(9). 压缩”- nocompress
- compress
(10). 延时压缩
Section titled “(10). 延时压缩”- delaycompress
- nodelaycompress
(11). 在所有其它指令完成前执行
Section titled “(11). 在所有其它指令完成前执行”- prerotate
- endscript
(12). 在所有其它指令完成后执行
Section titled “(12). 在所有其它指令完成后执行”- postrotate
- endscript
(13). 共享脚本
Section titled “(13). 共享脚本”- sharedscripts
(14). 错误信息发送到指定的Email地址
Section titled “(14). 错误信息发送到指定的Email地址”- errors address
(15). 转储的日志文件发送到指定的E-mail地址
Section titled “(15). 转储的日志文件发送到指定的E-mail地址”- mail address
- nomail
(16). 空文件也转储
Section titled “(16). 空文件也转储”- ifempty
- notifempty
(17). 指定转存目录
Section titled “(17). 指定转存目录”- olddir directory
- noolddir
(18). 日志日期后缀
Section titled “(18). 日志日期后缀”- dateext
(19). 日志格式
Section titled “(19). 日志格式”- dateformat
(20). 日期提前一天
Section titled “(20). 日期提前一天”- dateyesterday
(21). 指定文件的后缀
Section titled “(21). 指定文件的后缀”- extension
[1]. https://blog.csdn.net/xiaojin21cen/article/details/122309230