Changes

Linux System Log Rotation

2,465 bytes added, 00:21, 27 April 2013
The following lines were added (+) and removed (-):
 <nowiki>/etc/logrotate.d</nowiki> <nowiki>/etc/logrotate.d</nowiki> Test without actually rotating and show details: logrotate -vd /etc/logrotate.conf == Virtual Host Log Rotation for Apache ==Many linux distributions include a utility called logrotate.d which is installed and configured by default.  It is configured to rotate the main Apache log file typically weekly or monthly.  Yet, Apache configuration for virtual hosts (virtual_host) suggests creating separate logs for each virtual host, and in a directory named for the site.  This is typically under the primary Apache log directory.  Consider a server where /var/log/apache2/access.log is the primary apache log, but there is a virtual host which a log under /var/log/apache2/www.smokinghotbabes.com/access.log. Now looking in /etc/logrotate.d/httpd the default config is: /var/log/apache2/*.log {    missingok    notifempty    postrotate /usr/bin/killall -HUP httpd    endscript }This default installed configuration for logrotate.d/httpd will only rotate the primary web site.  It will not rotate virtual host sites.  This can be amended by adding another part to the log rotation configuration script: /var/log/apache2/*.log {    missingok    notifempty    postrotate /usr/bin/killall -HUP httpd    endscript } /var/log/apache2/*/*.log {    missingok    notifempty    postrotate /usr/bin/killall -HUP httpd    endscript }== configuration testing and some important flags ===== Verbose ===-v  tells logrotate to say what it’s doing while it’s doing it. It’s very useful when trying to find out why logrotate doesn’t rotate a log when you want it to.=== Debug ===-d  tells logrotate to go through the motions of rotating logs but not actually rotate them.  Good for checking that the config file is formatted properly and that logrotate can find the log files it would rotate. It doesn’t actually run the rotations and it doesn’t test some parts of the process like the postrotate scripts.=== Force ===-f  forces logrotate to rotate all logs, whether or not they would normally need to be rotated at that time. == External Resources ==* [http://www.thegeekstuff.com/2010/07/logrotate-examples/ HowTo: The Ultimate Logrotate Command Tutorial with 10 Examples]* [http://aaron.kavlie.net/2010/05/server-admin/apache-logs-and-logrotate-d/ Apache logs and logrotate.d]* [http://www.rackspace.com/knowledge_center/article/understanding-logrotate-part-2 Understanding logrotate - part 2]&nbsp;
Bureaucrat, administrator
16,192
edits