LogRotate¶
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¶
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¶
3. Supported Parameters¶
(1). 切割周期¶
- daily: 切割周期为 每天
- weekly: 切割周期为 每周
- monthly: 切割周期为 每月
- yearly: 切割周期为 每年
(2). 转存大小¶
- size 50M
(3). 日志保存份数¶
- rotate 1
(4). 保留日志天数¶
- maxage 1
(5). 不转储指定扩展名的文件¶
- tabooext [+] list
(6). 忽略错误¶
- missingok
(7). 备份/截断¶
- copytruncate/nocopytruncate
(8). 创建权限¶
- create mode owner group
- nocreate
(9). 压缩¶
- nocompress
- compress
(10). 延时压缩¶
- delaycompress
- nodelaycompress
(11). 在所有其它指令完成前执行¶
- prerotate
- endscript
(12). 在所有其它指令完成后执行¶
- postrotate
- endscript
(13). 共享脚本¶
- sharedscripts
(14). 错误信息发送到指定的Email地址¶
- errors address
(15). 转储的日志文件发送到指定的E-mail地址¶
- mail address
- nomail
(16). 空文件也转储¶
- ifempty
- notifempty
(17). 指定转存目录¶
- olddir directory
- noolddir
(18). 日志日期后缀¶
- dateext
(19). 日志格式¶
- dateformat
(20). 日期提前一天¶
- dateyesterday
(21). 指定文件的后缀¶
- extension
REF¶
[1]. https://blog.csdn.net/xiaojin21cen/article/details/122309230
[2]. https://linux.die.net/man/8/logrotate