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?

Thanks!

Whity.

link|improve this question
feedback

2 Answers

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

/var/log/httpd/access_log {
    missingok
    notifempty
    sharedscripts
    daily
    rotate 90
    postrotate
        /sbin/service httpd reload > /dev/null 2>/dev/null || true
    endscript
    compress
}
link|improve this answer
feedback

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.

link|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. – Whity Oct 19 '11 at 9:09
feedback

Your Answer

 
or
required, but never shown

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