Reputation: 5962
I have apache running on different servers, I would like to rsync log files back to a centralised server on a daily basis. I can use log rotate to create log file for a day and put it in a directory that gets rsync'd to the central server. However is there any way to set the log filename with a designation that could be read from an external file?
The documentation says I can do the following, CustomLog "|/usr/sbin/rotatelogs -f /var/log/httpd/log 86400" common
I have an external config file which has a designation field which I can parse from command line to get its value, is there any way I can add it when file name gets defined. I'm curious to know if this designation can be passed to apache as an environment variable and use that in apache's config. Is this possible?
Many Thanks again guys!
Upvotes: 0
Views: 1037
Reputation: 185
I think you can do this by configuring Apache and logrotate. Logrotate is configured by scripts in the /etc/logrotate.d/ directory. For example, my default apache logrotate config file is: /etc/logrotate.d/httpd
/var/log/httpd/*log { missingok notifempty sharedscripts postrotate /bin/kill -HUP `cat /var/run/httpd.pid 2>/dev/null` 2> /dev/null || true endscript }
Check the logrotate man pages for the postrotate command. During the postrotate phase you could rename the log file and place it somewhere to be picked up by rsync.
Upvotes: 1