Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

So I have a number of apache logs I like to handle with logrotate on a developer box. Some of them are for user sandboxes, others are for staging versions and such.

The logrotate config looks like:

/home/developerx/logs/*.log {
    rotate 100
    olddir archive
        /sbin/service httpd reload > /dev/null 2>/dev/null || true

I would like to customize some of the settings for beta versus a sandbox, like rotate 10 instead of 100 for a sandbox. I could create a new context for this, but if I do the postrotate "reload" for multiple contexts I worry that the process will be reloaded multiple times.

As a secondary question, is there any way to determine the order in which logrotate will process these entries? Alphabetical by filename, and first-to-last within a file?

share|improve this question
up vote 1 down vote accepted

Yes, if you write a separate entry, and it will have a reload command, the http server will be reloaded twice.

I believe logrotate applies the rules just as you described. It includes files in logrotate.d directory and just works through them, first to last entry. I have a logrotate monitoring based on this fact: the last rule in one particularly tricky set of files has a postrotate script which echoes date +%j to a status file.

You can check all of the above with logrotate -d -f /etc/logrotate.conf where -d stands for 'debug'.

Apache, though, can use rotatelogs as a custom logger, and the CustomLog directive can be different for each of sites you have, so you can treat differenrt logs the different way and eliminate that reload problem.

share|improve this answer
Good to know about Apache and rotatelogs, though it doesn't appear to support rotation into a different directory. ( – Roger Halliburton Feb 25 '14 at 21:05

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.