I'm testing a logrotate configuration in /tmp
. I'd like
- to configure a default logrotate policy for
/tmp/*.log
files using my test configuration file/tmp/logrotate.conf
- to handle a particular log file
/tmp/special.log
with a different policy configured in a separate logrotate config test file:/tmp/logrotate.d/included
But logrotate's response to my configuration is to say:
error: /tmp/logrotate.d/included:1 duplicate log entry for /tmp/special.log
What should I do differently?
Here's my /tmp/logrotate.conf
compress
missingok
notifempty
size 512k
copytruncate
rotate 2
su
# here's my attempt at applying the default policy to all /tmp/*.log
/tmp/*.log {}
# and here I intend to include any overrides
include /tmp/logrotate.d/included
And here's /tmp/logrotate.d/included
/tmp/special.log {
size 300
}
Here's the debug output.
$ sudo logrotate -d ./logrotate.conf
reading config file ./logrotate.conf
including /tmp/logrotate.d/included
reading config file /tmp/logrotate.d/included
error: /tmp/logrotate.d/included:1 duplicate log entry for /tmp/special.log
Handling 2 logs
rotating pattern: /tmp/*.log 524288 bytes (2 rotations)
empty log files are not rotated, old logs are removed
considering log /tmp/normal.log
log does not need rotating
considering log /tmp/special.log
log does not need rotating
rotating pattern: /tmp/special.log 300 bytes (2 rotations)
empty log files are not rotated, old logs are removed
No logs found. Rotation not needed.
- The error surprises me because I thought according to the man page "Later config files may override the options given in earlier files, so the order in which the logrotate config files are listed is important."
- Why does it say at the end when handling pattern
/tmp/special.log
that no logs were found? The file/tmp/special.log
exists and is larger than 300 bytes.
/tmp/logrotate.d
- are you just testing from there rather than/etc/logrotate.d
? Can you post the command you used when you tested?/tmp
. With the current working directory of/tmp
I run this command:sudo logrotate -d ./logrotate.conf
<next sentence:>normal.log
andspecial.log
are owned by me.logrotate.conf
andlogrotated.d/included
are owned by root because when everything had been owned by me there was a permissions issue in changing some property while logrotate was running.switching euid to 0 and egid to 0 ... error: error switching euid to 0 and egid to 0: Operation not permitted