logrotate - 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
}
解决方案
该/etc/logrotate.conf
文件不应以这样的开头和{
结尾}
。
而且maxage
androtate
可能两者都不需要(我总是只使用rotate
,从不maxage
)。
之前{
应该有一个文件名,像这样:
/var/log/mylog {
...
}
您可能应该在/etc/logrotate.d
文件夹中添加和更改文件,而不是更改/etc/logrotate.conf
文件。(我认为可以更好地防止系统升级时的自动更改,并且更清洁)
推荐阅读
- ruby-on-rails - 在 Rails 中查看管理员
- mysql - 不能查询超过 30 天
- java - 使用 FastParse 解析缩进
- angular - 如何防止点击Angular 4中的自定义按钮组件
- wordpress - wordpress 错误:图标仅在我登录时出现
- wordpress - 如何在登录时仅动态更改主 Wordpress 菜单?
- javascript - Wordpress:在模板中编辑帖子中的日期、作者和其他内容
- ms-access - 每天的第一条记录
- django - Django 1.11 查询集:获取关系集的所有对象(模型实例)
- database - 数据透视图/数据透视表空白/缺失数据隐藏在表上