一些文件被压缩到 1.gz
/var/log/apt/history.log.1.gz
/var/log/apt/term.log.1.gz
/var/log/mosquitto/mosquitto.log.1.gz
/var/log/mysql/error.log.1.gz
有的没有压缩,第一二级是到2.gz
/var/log/apache2/access.log.1
/var/log/apache2/error.log.1
/var/log/apache2/other_vhosts_access.log.1
/var/log/dbconfig-common/dbc.log.1
/var/log/exim4/mainlog.1
/var/log/letsencrypt/letsencrypt.log.1
我有时会在邮件中收到错误消息:
/etc/cron.daily/logrotate:
error: Compressing program wrote following message to stderr
when compressing log /var/log/mosquitto/mosquitto.log.1:
gzip: stdin: file size changed while zipping
因为 mosquitto 在旋转时似乎会写入日志。
旋转脚本是 debian 默认安装的:
/var/log/mosquitto/mosquitto.log {
rotate 7
daily
compress
size 100k
nocreate
missingok
postrotate
/usr/bin/killall -HUP mosquitto
endscript
}
我也更喜欢未压缩的最新日志。
我想我找到了解决方案:其他脚本包含关键字
据该男子称,它会将压缩延迟一个周期。
您错过了这个重要的选项,以避免在压缩阶段更改文件: