Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Automatically empty Apache error log files' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Automatically empty Apache error log files
Authored by: cilly on Oct 04, '04 08:14:57PM
It is better to edit the weekly crontab located at:

/etc/periodic/weekly/500.weekly

I added the following section after the /var/log part:

cd /var/log/httpd
for i in access_log agent_log error_log referer_log ssl_engine_log ssl_request_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

---
cilly @ http://www.cilly.dyndns.org/

[ Reply to This | # ]