Skip to content

Instantly share code, notes, and snippets.

@alces
Last active October 13, 2015 07:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alces/3bae1203781f955d3cfa to your computer and use it in GitHub Desktop.
Save alces/3bae1203781f955d3cfa to your computer and use it in GitHub Desktop.
logrotate config for apache with rotating by files' size and gathering statistics from the old logs before compressing them.

Put the following into your /etc/logrotate.d/httpd:

# use the standard parameters for error log
/var/log/httpd/error_log {
    missingok
    notifempty
    sharedscripts
    postrotate
	/sbin/service httpd graceful 2> /dev/null || true
    endscript
}

# and the non-standard ones for access log
/var/log/httpd/access_log {
    compress
    size 256M
    rotate 9
    nodateext
    missingok
    notifempty
    sharedscripts
    postrotate
	/sbin/service httpd graceful 2> /dev/null || true
	/path/to/your/stat/script < /var/log/httpd/access_log.1
    endscript
}

And DON'T FORGET to move your /etc/cron.daily/logrotate to /etc/cron.hourly/ (of course, if your logs grow fast enoght)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment