Apache Log Rotation?

Dris

The Benevolent
It seems that my Apache logs are being automatically rotated every week or so... I'm unable to figure out why. I only seems to have been doing this since I installed Panther.

After a while, I'll notice that my site's statistics have started from scratch. I look in the logs directory and find last week's logs saved as "access_log.0.gz", along with the others. This only seems to happen with the access_log and the error_log; the referer_log and agent_log seem to remain untouched.

I'm using Analog to get the statistics.

Here's my question. I want to disable this automatic rotation. I can't seem to find a line for it in the Apache configuration or the Analog configuration. Anybody know what's causing this? Thanks!
 
Yes, it's part of the daily cleanup scripts run by cron.

Edit /etc/periodic/daily/500.daily and delete this block of text from it:

Code:
if [ -d /var/log/httpd ]; then
    echo ""
    echo -n "Cleaning web server log files:"
    cd /var/log/httpd && \
        find . -type f -name '*_log*' -mtime +7 -exec rm -f -- {} \; >/dev/null 2>&1;
fi

(Why they put that in the daily script rather than the weekly one is beyond me. :p)
 
Hmm, actually, it is in the weekly script - that one in the daily script just deletes anything in /var/log/httpd that hasn't been modified in 7 or more days. Oops on my part.

To stop the log rotation, edit /etc/periodic/weekly/500.weekly, and delete these lines:

Code:
cd /var/log/httpd
for i in access_log error_log; do
    if [ -f "${i}" ]; then
        echo -n " $i"
        if [ -x /usr/bin/gzip ]; then gzext=".gz"; else gzext=""; fi
        if [ -f "${i}.3${gzext}" ]; then mv -f "${i}.3${gzext}" "${i}.4${gzext}"; fi
        if [ -f "${i}.2${gzext}" ]; then mv -f "${i}.2${gzext}" "${i}.3${gzext}"; fi
        if [ -f "${i}.1${gzext}" ]; then mv -f "${i}.1${gzext}" "${i}.2${gzext}"; fi
        if [ -f "${i}.0${gzext}" ]; then mv -f "${i}.0${gzext}" "${i}.1${gzext}"; fi
        if [ -f "${i}" ]; then mv -f "${i}" "${i}.0" && if [ -x /usr/bin/gzip ]; then gzip -9 "${i}.0"; fi; fi
        touch "${i}" && chmod 640 "${i}" && chown root:admin "${i}"
    fi
done

(There's also a line under that that will restart the webserver every week - you might want to delete that one too if you don't want the webserver to be restarted weekly.)
 
Back
Top