Situation: You have your website running on an Apache web server and you're using awstats for your web statistics. You have a daily cronjob which starts the awstats script like this:
The above command launches the awstats script with a config /etc/awstats/awstats.www.claudiokuenzler.com.conf.
But as the log file grows and grows, you want of course to rotate the log files.
Problem: When you rotate the log file, awstats doesn't know about it and looses all visitor data now stored in the rotated access log. And afaik, there is no config parameter to tell awstats about a location/path of a rotated log file.
To solve that issue, awstats can be called during the log rotation phase:
/usr/lib/cgi-bin/awstats.pl -config=www.claudiokuenzler.com > /dev/null
/etc/init.d/apache2 reload > /dev/null
Besides the obvious logrotate options, the magic happens in the prerotate section: Right before rotating the log file(s), launch the awstats command and analyze the access log.
After the log was rotated, the postrotate section starts and reloads Apache (to prevent the Apache process of writing into the previous log file's inode).
Granted, during the time awstats is running, there could be several new hits on the website and therefore new entries in the access log. But on my site the lost statistics are marginal (and honestly not that important).