首页 > 解决方案 > Logrotate,我的 custom.conf 文件没有处理旧的日志文件

问题描述

我的 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
}

标签: logrotate

解决方案


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

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

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

/var/log/mylog {
...
}

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


推荐阅读