【发布时间】:2015-02-08 10:57:51
【问题描述】:
我有以下设置:从/etc/logrotate.d/syslog 文件中删除包含/var/log/maillog 的行,并在/etc/logrotate.conf 文件中添加以下内容:
...
# system-specific logs may be also be configured here.
/var/log/maillog
{
missingok
notifempty
nocompress
size=50k
postrotate
touch /var/log/maillog
endscript
}
为什么当文件大小达到 50k 时,touch /var/log/maillog 行永远不会被执行?
【问题讨论】:
-
如果你运行
logrotate -d /etc/logrotate.conf,你会看到什么文件? -
...
reading config info for /var/log/maillog...rotating pattern: /var/log/maillog 51200 bytes (10 rotations) empty log files are not rotated, old logs are removed considering log /var/log/maillog log needs rotating rotating log /var/log/maillog, log->rotateCount is 10 dateext suffix '-20141210' glob pattern '-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]' destination /var/log/maillog-20141210 already exists, skipping rotation -
最后一行似乎是我认为的关键。
destination /var/log/maillog-20141210 already exists, skipping rotation我不确定这应该如何与日期扩展一起使用。