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

I need Apache accesslog file to be parsed fast in realtime and always to keep only last 3 months data. So I need tool which everyday cutting old records(and moving them to another file) from log file while keeping same filename for main access_log.

Is it possible with logrotate?



share|improve this question

Sure, you can do it with logrotate, something like this:

/var/log/httpd/access_log {
    rotate 90
        /sbin/service httpd reload > /dev/null 2>/dev/null || true
share|improve this answer

I don't know the purposes, but as I guess it would be a better way to use mod_log_sql for access logging. It stores access information into a database table, by inserting a record for each request. Then this table can be queried to obtain the desired information from the access log which is a much faster way than parsing a text file. Hence it will result in a faster log processing, without lack of deleting or moving information from one place to another.

share|improve this answer
I need it for awstats to show only last 3 month of data. One of its plugin very slow when parsing long log files. – Boris Ivanov Oct 19 '11 at 9:09

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.