Niall O Broin
2009-07-01 12:52:07 UTC
When using logrotate with wildcards, you can specify that a postrotate
script should only run once so that if e.g. you were rotating a bunch
of log files from one apache server, you would only restart apache once.
However, I have a slightly different requirement - I'd like to run the
postrotate script once for each log file (in this case I'm rotating
production.log files for Rails apps running under passenger) hence I'd
use nosharedscripts (which is anyway the default) but I need to pass
the script a parameter which is the name of the log file which was
just rotated (so that passenger can restart the appropriate Rails
instance). Ideally, I'd like to be able to have a logrotate.d/rails
config like this
/APPSBASE/*/shared/log/production.log {
daily
missingok
rotate 7
compress
delaycompress
sharedscripts
postrotate
passenger_restart $LOG
endscript
where passenger_restart is a script which will restart passenger for a
given app, given its production log file name, and $LOG is the
particular log file which has now been matched by the wildcard. Sadly,
logrotate doesn't seem to have the ability to produce $LOG.
The only idea I have is to generate the logrotate.d/rails config file
on the fly each time which would work, and wouldn't be particularly
difficult, but it's a bit of a kludge - I'd prefer a solution whch
works entirely within logrotate.
I have RTFM and STFW but with no success, so as a last resort I turn
to the collective wisdom of ILUG - any ideas?
Niall
script should only run once so that if e.g. you were rotating a bunch
of log files from one apache server, you would only restart apache once.
However, I have a slightly different requirement - I'd like to run the
postrotate script once for each log file (in this case I'm rotating
production.log files for Rails apps running under passenger) hence I'd
use nosharedscripts (which is anyway the default) but I need to pass
the script a parameter which is the name of the log file which was
just rotated (so that passenger can restart the appropriate Rails
instance). Ideally, I'd like to be able to have a logrotate.d/rails
config like this
/APPSBASE/*/shared/log/production.log {
daily
missingok
rotate 7
compress
delaycompress
sharedscripts
postrotate
passenger_restart $LOG
endscript
where passenger_restart is a script which will restart passenger for a
given app, given its production log file name, and $LOG is the
particular log file which has now been matched by the wildcard. Sadly,
logrotate doesn't seem to have the ability to produce $LOG.
The only idea I have is to generate the logrotate.d/rails config file
on the fly each time which would work, and wouldn't be particularly
difficult, but it's a bit of a kludge - I'd prefer a solution whch
works entirely within logrotate.
I have RTFM and STFW but with no success, so as a last resort I turn
to the collective wisdom of ILUG - any ideas?
Niall
--
Irish Linux Users' Group mailing list
About this list : http://mail.linux.ie/mailman/listinfo/ilug
Who we are : http://www.linux.ie/
Where we are : http://www.linux.ie/map/
Irish Linux Users' Group mailing list
About this list : http://mail.linux.ie/mailman/listinfo/ilug
Who we are : http://www.linux.ie/
Where we are : http://www.linux.ie/map/