Does the sharedscripts setting for logrotate apply to all processed logs, or only those in the current context

logrotate

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?

Best Answer

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.

Related Topic