0

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.

Boris Ivanov
  • 161
  • 8

2 Answers2

0

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
}
quanta
  • 51,413
  • 19
  • 159
  • 217
0

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.

torokg
  • 101
  • 1