from small one page howto to huge articles all in one place

search text in:

Which screen resolution do you use?

poll results

Last additions:
using iotop to find disk usage hogs

using iotop to find disk usage hogs






average rating: 1.7 (102 votes) (1=very good 6=terrible)

May 25th. 2007:




why adblockers are bad

Workaround and fixes for the current Core Dump Handling vulnerability affected kernels

Workaround and fixes for the current Core Dump Handling vulnerability affected kernels






average rating: 1.4 (42 votes) (1=very good 6=terrible)

April, 26th. 2006:

Druckversion . pdf icon
You are here: System

rotating apache logfiles with cronolog

When your webserver has a couple of hits per day your logfile will increase to a limit when it becomes difficult to handle.

You can use a lot of ways to rotate your logfile automatically.

One of this possibilities is cronolog.

First, you have to install cronolog with the install tool for your distribution, which is quite painless.

Now you have to configure the apache logfile. Normally you already have a line like
CustomLog /some/path/transfer.log" combined

all you have to do is change the line to a line similar to this:
CustomLog "|/path/to/cronolog /some/path/transfer-%Y-%m-%d.log" combined

This would create a logfile for each day in the given path. A description of the % template is at the website for cronolog.
The files will be named after the template you give, if you want to have somewhere else or a different template for the filename, adjust it to your liking.

there is just one problem...

Normally you have a program to generate stats from your logfile. Now they are unable to find the logfile, because the name changes every once in a while.
But luckily, the cronolog has the feature to create a symlink to the current logfile. That way there is a static filename to the most recent log file.

Just make sure, you run the stats tool before the log gets rotated.
But you will loose the info between the last run and the new logfile. This can be corrected if you run the stats tool after the rotation on the last logfile once.

cronolog does provide a symlink there, too.
CustomLog "|/usr/sbin/cronolog -S /some/path/transfer.log -P /some/path/transfer.log.old
/some/path/transfer-%Y-%m-%d.log" combined

(line splitted for readability, it is one line)

All you have to change is the crontab for your stats tool to normally use the transfer.log and run once after the rotation on transfer.log.old
an example for awstats:
/path/to/ -logfile /some/path/transfer.log.old

rate this article:
current rating: average rating: 1.1 (178 votes) (1=very good 6=terrible)
Your rating:
Very good (1) Good (2) ok (3) average (4) bad (5) terrible (6)


Support us on Content Nation
rdf newsfeed | rss newsfeed | Atom newsfeed
- Powered by LeopardCMS - Running on Gentoo -
Copyright 2004-2020 Sascha Nitsch Unternehmensberatung GmbH
Valid XHTML1.1 : Valid CSS : buttonmaker
- Level Triple-A Conformance to Web Content Accessibility Guidelines 1.0 -
- Copyright and legal notices -
Time to create this page: 42.4 ms