Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I have a logrotate.d config file that looks something like this:

/home/myapp/log/* {
    olddir /home/myapp/baklog

There are a few particular log files where I want to apply additional rules, such as "mail". How can I apply additional rules to just some files?

If I add another rule above that matches the additional files (e.g. /home/myapp/log/warning.log { ... }, I get an error like error: /etc/logrotate.d/myapp:3 duplicate log entry for /home/myapp/log/warning.log.

How can I specify multiple rules that match particular files in an overlapping kind of way?

share|improve this question

migrated from superuser.com May 11 '12 at 0:48

This question came from our site for computer enthusiasts and power users.

1 Answer 1

You need to move the more specific override definition to a separate configuration file. Then give both configuration files on the command line with the more specific one second.

share|improve this answer
The problem is the same as if I had the override in a single file (which is legal): if I have an override, I can't then use a wildcard for the rest of the files in that directory, without the error that I quoted in the question. If I am wrong, please provide a working example? –  Ether May 12 '12 at 0:54
@Ether, I'm still looking into it, but it looks like there was a decision made in Debian that allowing overrides of a rule for a specific file was bad because it became common for package installs to erroneously install duplicate rules and the logrotate maintainers wanted to flag that as an error. For now, use a wild card that excludes the files you want to set with different options. –  Old Pro May 12 '12 at 15:48
wildcards can't do exclusions - there is no way to say "everything but this one file". –  Ether May 14 '12 at 16:31
@Ether, true, you cannot specify "everything but this one file" in a wild card, but you could do something like [a-hj-z]* to select all files that begin with a lower case letter other than i. If your special file is the only one whose name begins with i then that would be "a wild card that excludes the files you want to set with different options". –  Old Pro May 14 '12 at 23:14
You could also change the application configuration to log the files you want to treat special into a different directory... I don't think logrotate is nearly sophisticated enough to do what you want or, in fact, should be. If the app is making arbitrarily named logs maybe you could put THOSE someplace different and then spec every log in this directory in two or three lists. –  Mark May 15 '12 at 15:11

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.