linux logrotate切割日志,最大的文件始终删除不了

1、logrotate配置如下:

/home/user02/log/log_0627* {
    size=5M
    rotate 2
    missingok
    dateext
    nocompress
    notifempty
    create 644 root root
    postrotate
        /usr/bin/killall -HUP rsyslogd
    endscript
}

2、起始用dd创建了一个10m的文件,然后使用logrotate -vf,发现不断在创建,数量超过2,最老的10m文件无法删除

clipboard.png

求大神解答

阅读 3k
1 个回答

man logrotate

Please use wildcards with caution. If you specify *, logrotate will rotate all files, including previously rotated ones. A way around this is to use the olddir directive or a more exact wildcard (such as *.log).

/home/user02/log/log_0627* 会把生成备份文件也当成原始文件进行控制的,所以不会删除。

* 去掉吧。

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题