2

I need to change the log retention for apache, currently is seems to be running on the default from logrotate.conf which is weekly. It creates 'access_log.1' 'access_log.2' and so on for each week. The problem is it deletes the last log file every week, 'access_log.5', I need the logs to keep going infinitely instead of the last log being deleted every week. It seems to be running on the default value from logrotate.conf - I don't want to change the default values held in that file, so I assume there is a way to change the retention using the /etc/logrotate.d/httpd file?

the contents are as follows:

/var/log/httpd/*log {
    missingok
    notifempty
    sharedscripts
    postrotate
        /sbin/service httpd reload > /dev/null 2>/dev/null || true
    endscript
}

what can I add/change to stop the last log being deleted every week?

2 Answers 2

3

You would need to add the rotate {value} option to tell logrotate how many copies to keep. The below will keep 52 copies.

/var/log/httpd/*log {
    missingok
    rotate 52
    notifempty
    sharedscripts
    postrotate
    /sbin/service httpd reload > /dev/null 2>/dev/null || true
    endscript
}
2
0

It is surprisingly difficult to find an answer to this question. I ended up finding this obscure 2003 forum post. The solution seems to be that you just disable the cronjob for logrotate at which by default is maybe at /etc/cron.daily/logrotate. This disables all rotation of logs everywhere on the machine, which is what I wanted. If you only want to do this for a specific application, I think you can maybe get away with creating an empty config file in /etc/logrotate.d/apache2. If you just delete this config file, I think it will default back to the global one at /etc/logrotate.conf and still rotate.

You must log in to answer this question.