So if you have installed AWstats, a web-statistic program, on your machine you would have noticed that the cron job that it sets by default does not work. Meaning that the statistics on your AWstats web page does not get updated. If you do a search on Internet, you will find that lot of Ubuntu and Debian folks are facing the same problem. Also there are lot of other suggestions (but dangerous) that are given to make it work, but I have found the following solution to the most (but not completely) safest of all.

Let’s first take a look at the cron job that gets installed by default when you install AWstats in Debian Lenny:

debian:~# cat /etc/cron.d/awstats
0,10,20,30,40,50 * * * * www-data [ -x /usr/lib/cgi-bin/ -a -f /etc/awstats/awstats.conf -a -r /var/log/apache2/access.log ] && /usr/lib/cgi-bin/ -update>/dev/null

Now if you read the Debian specific README file at:

it will say giving proper “read” permission to access.log file at /var/log/apache2/. Now even after giving read permission to that file, the “www-data” user is not able to access the apache log files. You can verify this by running the following command:
debian:~# sudo -u www-data /usr/bin/perl /usr/lib/cgi-bin/ -update

Create/Update database for config "/etc/awstats/" by AWStats version 6.7 (build 1.892)
From data in log file "/var/log/apache2/access.log"...
Error: Couldn't open server log file "/var/log/apache2/access.log" : Permission denied
Setup ('/etc/awstats/' file web server or permissions) may be wrong.
Check config file permissions and AWStats documentation (in 'docs' directory).

That’s right, even after giving read permission to access.log file, it still cannot read it.

After a lot of researching I finally tried the following command:

# chmod 755 -R /var/log/apache2/*

The above command makes the files “readable” and “executable” for the group “adm” and for “others” user.

Now the cron job, /etc/cron.d/awstats, will execute just fine you should be able to see your server’s statistics at:

Also if anyone of you find a better solution than above, please post it in the comment section below.

Happy CRON’ing!

Be Sociable, Share!