Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Since the man page doesn't answer my question and I don't want to force a rotation cycle, I decided to ask the question here.

The man page for logrotate gives the following example:

   "/var/log/httpd/access.log" /var/log/httpd/error.log {
       rotate 5
       mail www@my.org
       size 100k
       sharedscripts
       postrotate
           /usr/bin/killall -HUP httpd
       endscript
   }

All examples with wildcards contain only a single entry. Now, what I'm interested in is whether this one is also allowed:

   /var/log/httpd/*.log /var/log/httpd/*/*.log {
       # ... same as above
   }

Here's the reasoning: I have multiple vhosts and I split them up by the user that "owns" those vhosts. Since the log files are world-readable, I want to bind-mount a folder into the user home directory, but limit it to the log files that the user "owns", which is easiest achieved by separating the logs into folders (and bind-mounting requires that scheme anyway). So I'm looking for a solution to rotate both the log files under /var/log/httpd as well as all log files under subdirectories of that directory - without having to list each and every subdirectory by name.

In general the man page gives no clue whether multiple entries are at all possible for wildcard rules or only for full paths. I'm using logrotate version 3.7.8-6 which comes with Debian "Squeeze", but I reckon this is not necessarily specific to a distro or program version.

share|improve this question

1 Answer 1

up vote 44 down vote accepted

Yes, you can use multiple wild cards. You can test your file without performing the actual rotations by doing this:

logrotate -d -f /etc/logrotate.conf
  • -d = Turns on debug mode. In debug mode, no changes will be made to the logs or to the logrotate state file.

  • -f = Tells logrotate to force the rotation, even if it doesn’t think this is necessary. Sometimes this is useful after adding new entries to logrotate, or if old log files have been removed by hand, as the new files will be created, and logging will con- tinue correctly.`

share|improve this answer
1  
thanks a lot! Just tried and it works. It appears from the output that the wildcards can be expected to work as they do in the shell. –  0xC0000022L Mar 10 '11 at 23:01

Your Answer

 
discard

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.