suanziliu
suanziliu

Reputation: 157

logrotate: error opening <log>.gz

I'm now setting up logrotate on ubuntu to rotate logs. This is my config:

/etc/logrotate.d/test:

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

In /var/log/test, it has following test log files:

-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

When I run logrotate -d -v test, it told me no all logs does not need rotating:

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

When I run logrotate -d -v test -f, it give me errors like following:

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

Can anyone help me with this?

Upvotes: 5

Views: 2010

Answers (1)

parttimeturtle
parttimeturtle

Reputation: 1215

I don't know if you have missingok as a default parameter inside your logrotate.conf file, but without it, logrotate is going to complain about those missing files. See man logrotate:

missingok

If the log file is missing, go on to the next one without issuing an error message.

Upvotes: 2

Related Questions