Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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.

share|improve this question

2 Answers 2

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
}
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

 
discard

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.