Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This might be a simple question. How do you rotate Apache logs daily?

share|improve this question
Why the down vote? isn't this a valid questions? – Mary Sep 1 '11 at 3:08
Mary - I can't speak for the downvoter, but my guess is that the downvote was because this is something that is easily discoverable by a simple Google search, and you showed no evidence that you had tried to research it yourself. – EEAA Sep 1 '11 at 3:46
In her defence, this is what I found by a simple Google search. – Kenzo Mar 2 '14 at 1:43

Put the below lines into /etc/logrotate.d/httpd:

/var/log/httpd/*log {
    rotate 7
        /sbin/service httpd reload > /var/log/httpd/rotate 2>&1 || true
share|improve this answer
See… if you want to do this for more than one log directory. – SPRBRN May 6 '14 at 14:48

On a Linux system you would usually setup logrotate.

You could also use something like cronolog.

share|improve this answer

It's perhaps a bit more elegant to use the Apache 'rotatelogs' program, imo.

Here's an example from one of my servers:

# Seo logs, rotated daily, on GMT clock
LogFormat "%h %t %D \"%r\" %>s \"%{Referer}i\" \"%{User-Agent}i\" %{Host}i" seo
CustomLog "|/usr/sbin/rotatelogs /etc/httpd/logs/seo_log.%Y%m%d 86400" seo

You can also set a GMT offset for localtime, or specify rotation based on filesize.

'man rotatelogs'.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.