【问题标题】:Logrotate, my custom.conf file is not disposing old log filesLogrotate,我的 custom.conf 文件没有处理旧的日志文件
【发布时间】:2018-10-15 11:58:15
【问题描述】:

我的用于 logrotate 的 custom.conf 文件只执行旧文件的重命名,但在我的 maxage 日之后不处理它们。我可以看到它旋转文件。 custom.conf 文件保存到 /etc/logrotate.d/ 目录。有人可以告诉我我是否在这里遗漏了什么? 它只是继续在我的日志文件末尾添加以前的日期 *.log-20180428-20180430-20180502-20180504。

这里是 custom.conf 文件(注意:directory_name 路径是挂载的驱动器。)

/directory_name/*/*/*.log* 
/directory_name/*/*.log* 
{
    daily
    compress
    delaycompress
    rotate 4
    ifempty
    maxage 4
    nocreate
    missingok
    sharedscripts
    postrotate
    /bin/kill -HUP `cat /var/run/syslogd-ng.pid 2> /dev/null` 2> /dev/null || true
    endscript
}

【问题讨论】:

  • 也许*.log* 应该只是*.log 没有结尾*。这可能是文件名中添加更多日期的原因。

标签: logrotate


【解决方案1】:

/etc/logrotate.conf 文件不应像这样以 {} 开头和结尾。

maxagerotate 可能两者都不需要(我总是只使用rotate,从不使用maxage)。

{之前应该有一个文件名,像这样:

/var/log/mylog {
...
}

您可能应该在/etc/logrotate.d 文件夹中添加和更改文件,而不是更改/etc/logrotate.conf 文件。 (我认为可以更好地防止系统升级时的自动更改,并且更干净)

【讨论】:

  • 为了清楚起见,我已经编辑了我的主题行和原始 cmets。
猜你喜欢
  • 1970-01-01
  • 2018-04-14
  • 1970-01-01
  • 2013-07-10
  • 1970-01-01
  • 2012-02-16
  • 2013-01-29
  • 2018-04-14
  • 2018-10-12
相关资源
最近更新 更多