logrotate:错误打开<log> .gz

时间:2018-04-12 07:09:10

标签: ubuntu logrotate

我现在正在ubuntu上设置logrotate来旋转日志。这是我的配置:

/etc/logrotate.d/test

/var/log/test/*.log{
  weekly
  rotate 7
  compress
  delaycompress
  notifempty
  create 640 testuser testgroup
}

在/ var / log / test中,它有以下测试日志文件:

-rw-r--r--  1 testuser testgroup 0 四月  1 00:00 2018-04-01.log
-rw-r--r--  1 testuser testgroup 0 四月  1 00:00 2018-04-02.log
-rw-r--r--  1 testuser testgroup 0 四月  1 00:00 2018-04-03.log
-rw-r--r--  1 testuser testgroup 0 四月  1 00:00 2018-04-04.log
-rw-r--r--  1 testuser testgroup 0 四月  1 00:00 2018-04-05.log
-rw-r--r--  1 testuser testgroup 0 四月  1 00:00 2018-04-06.log
-rw-r--r--  1 testuser testgroup 39 四月  1 00:00 2018-04-08.log
-rw-r--r--  1 testuser testgroup 0 四月  1 00:00 2018-04-09.log
-rw-r--r--  1 testuser testgroup 391938 四月  1 00:00 scheduler.log

当我运行logrotate -d -v test时,它告诉我没有所有日志都不需要旋转:

reading config file zctest

Handling 1 logs

rotating pattern: /var/log/test/*.log  weekly (7 rotations)
empty log files are not rotated, old logs are removed
considering log /var/log/test/2018-04-01.log
  log does not need rotating
considering log /var/log/test/2018-04-02.log
......
considering log /var/log/test/2018-04-02.log

当我运行logrotate -d -v test -f时,它会给出如下错误:

renaming /var/log/KeyServer/2018-04-08.log.1.gz to 
/var/log/KeyServer/2018-04-08.log.2.gz (rotatecount 7, logstart 1, i 1), 
renaming /var/log/KeyServer/2018-04-08.log.0.gz to 
/var/log/KeyServer/2018-04-08.log.1.gz (rotatecount 7, logstart 1, i 0), 
renaming /var/log/KeyServer/2018-04-08.log to /var/log/KeyServer/2018-04-08.log.1
creating new /var/log/KeyServer/2018-04-08.log mode = 0640 uid = 1000 gid = 1000
removing old log /var/log/KeyServer/2018-04-08.log.8.gz
error: error opening /var/log/KeyServer/2018-04-08.log.8.gz: No such file or directory

任何人都可以帮我吗?

1 个答案:

答案 0 :(得分:0)

我不知道您的logrotate.conf文件中是否有missingok作为默认参数,但是如果没有它,logrotate将会抱怨那些丢失的文件。参见man logrotate

  

missingok

     
    

如果缺少日志文件,请继续执行下一个而不发出错误消息。