我有一个 logrotate conf:
/myapps/log.log {
missingok
notifempty
rotate 9
copy
}
Run Code Online (Sandbox Code Playgroud)
然后当我运行 /usr/sbin/logrotate -d -f logrotate.conf
它给出了错误:
renaming /myapps/log.log.2 to /myapps/log.log.3 (rotatecount 2, logstart 1, i 2)
renaming /myapps/log.log.1 to /myapps/log.log.2 (rotatecount 2, logstart 1, i 1)
renaming /myapps/log.log.0 to /myapps/log.log.1 (rotatecount 2, logstart 1, i 0)
copying /myapps/log.log to /myapps/log.log.1
Not truncating /myapps/log.log.3
error: error opening /myapps/log.log.3: No such file or directory
Run Code Online (Sandbox Code Playgroud)
我还没有 log.log.3,所以它不存在,但正因为如此,logrotate 根本不起作用,我该如何修复它。
小智 0
在我自己遇到这个问题之后,我了解到该-d标志将在调试模式下运行 logrotate,除了抛出该错误之外,它实际上不会执行任何操作。尝试不要在调试模式下运行它,我的猜测是它可以解决您的问题。
https://github.com/logrotate/logrotate/issues/165