Logrotate 说它旋转但不旋转

Logrotate 说它旋转但不旋转

我在 Raspbian 9 系统上遇到了 logrotate 的奇怪问题。

Logrotate 似乎配置为每 7 天轮换一次 /var/log/syslog。当我运行时,logrotate -f -d /etc/logrotate.conf输出告诉我:

rotating pattern: /var/log/syslog
 forced from command line (7 rotations)
empty log files are not rotated, old logs are removed
considering log /var/log/syslog
  Now: 2021-03-16 09:56
  Last rotated at 2020-11-02 12:26
  log needs rotating
rotating log /var/log/syslog, log->rotateCount is 7
dateext suffix '-20210316'
glob pattern '-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]'
compressing log with: /bin/gzip
renaming /var/log/syslog.7.gz to /var/log/syslog.8.gz (rotatecount 7, logstart 1, i 7),
renaming /var/log/syslog.6.gz to /var/log/syslog.7.gz (rotatecount 7, logstart 1, i 6),
renaming /var/log/syslog.5.gz to /var/log/syslog.6.gz (rotatecount 7, logstart 1, i 5),
renaming /var/log/syslog.4.gz to /var/log/syslog.5.gz (rotatecount 7, logstart 1, i 4),
renaming /var/log/syslog.3.gz to /var/log/syslog.4.gz (rotatecount 7, logstart 1, i 3),
renaming /var/log/syslog.2.gz to /var/log/syslog.3.gz (rotatecount 7, logstart 1, i 2),
renaming /var/log/syslog.1.gz to /var/log/syslog.2.gz (rotatecount 7, logstart 1, i 1),
renaming /var/log/syslog.0.gz to /var/log/syslog.1.gz (rotatecount 7, logstart 1, i 0),
log /var/log/syslog.8.gz doesn't exist -- won't try to dispose of it
renaming /var/log/syslog to /var/log/syslog.1
creating new /var/log/syslog mode = 0640 uid = 0 gid = 4
running postrotate script
running script with arg /var/log/syslog: "
                invoke-rc.d rsyslog rotate > /dev/null
"

所以它说它正在重命名/var/log/syslog/var/log/syslog.1创建一个新的syslog.所以到目前为止一切似乎都很好。

只是,它确实注意到了。之后就没有syslog.1了,syslog文件和之前一样。什么都没发生。

有一件事要提: /var/log 是 tmpfs - 这有关系吗?安装为:tmpfs on /var/log type tmpfs (rw,nosuid,nodev,relatime)

感谢您的想法!

/克内布

答案1

你说你要跑步logrotate -f -d /etc/logrotate.conf

选项的描述-d(强调我的):

-d,--调试

打开调试模式,这意味着没有对日志进行任何更改并且 logrotate 状态文件未更新。仅打印调试消息。

不带该选项再试一次-d

相关内容