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

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:

/srv/www/logs/beta/*log
/srv/www/logs/www/*log
/home/developerx/logs/*.log {
    daily
    rotate 100
    olddir archive
    sharedscripts
    postrotate
        /sbin/service httpd reload > /dev/null 2>/dev/null || true
    endscript
}

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

1 Answer 1

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. (httpd.apache.org/docs/current/programs/rotatelogs.html) –  Roger Halliburton Feb 25 at 21:05

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.