Logrotate 创建空的旋转文件

Nix*_*Man 4 logrotate cron

我为日志的日志轮换设置了以下参数。size=10M, rotate 800, copytruncate, missingok. 正在创建 800 个旋转文件,但其中许多文件小于 10M,其中一些文件为 0 大小的空文件。

我有一个 cron 设置,* * * * *它每分钟运行一次来​​执行这个 logrotation。我不想要这个,无法理解为什么会这样。

0xF*_*xFF 5

尝试这个选项:

notifempty
    Do not rotate the log if it is empty (this overrides the ifempty option).
Run Code Online (Sandbox Code Playgroud)

来源: http: //linux.die.net/man/8/logrotate


小智 5

即使我有同样的问题,在添加“nocreate”选项后问题也解决了。

/opt/postgres/9.1/data/pg_log/postgresql*.log {
        missingok
        compress
        daily
        rotate 7
        maxage 7
        minsize 5
        notifempty
        size 5M
    nocreate
}
Run Code Online (Sandbox Code Playgroud)