【问题标题】:logrotate even empty fileslogrotate 甚至是空文件
【发布时间】:2017-02-15 15:35:00
【问题描述】:

我在 cron 作业中运行 logrotate 时遇到问题:尺寸太小的文件无法旋转。

我希望旋转所有文件,即使是大小等于 0 的文件。 这是我的配置

/logs/server-*.log {
    rotate 1
    missingok
    compress
    sharedscripts
    copytruncate
    dateext
    dateformat %Y-%m-%d-%s
    lastaction
    # scripts to move *.gz files here
    endscript
}

请指教。 我正在运行 Ubuntu 14.04 服务器

【问题讨论】:

    标签: cron logrotate


    【解决方案1】:

    据我所知,您现在要求的是默认的 Logrotate 行为。但是,您可以显式添加 ifempty 配置:

    /logs/server-*.log {
    
        # Rotate the log file even if it is empty, 
        # overriding the notifempty option (ifempty is the default).
        ifempty
    
        rotate 1
        missingok
        compress
        sharedscripts
        copytruncate
        dateext
        dateformat %Y-%m-%d-%s
        lastaction
        # scripts to move *.gz files here
        endscript
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-09-29
      • 2019-09-19
      • 1970-01-01
      • 1970-01-01
      • 2022-08-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多