Disclaimer: This guide is not for pure beginners and you must have at least a basic knowledge of Linux commands to know what you are doing. We will not be held responsible for any loss or damage including without limitation, indirect or consequential loss or damage, or any loss or damage whatsoever arising from loss of data or profits arising out of, or in connection with, the use of the following guide. It is suggested that you backup every file involved in this guide beforehand.

Look for your DataDir of your website and remove the particular month of the file. In our case, we are using Virtualmin that installs the AWStats and by default the DataDir of the site is stored in /var/www/awstats/[site-domain]. For example, if the site domain is gix.my, the directory that stores all the AWstats data files would be in /var/www/awstats/gix.my. You may want to backup that folder first before you start to do anything with the files. Make sure that you have the old log files that needs to be processed by AWStats.

Let's say for example the current month is March 2013, but you wish to process the statistics data for the month of February 2013. One thing about AWStats is that if you wish to process previous months, you will need to remove starting from the current month. In this case, we will need to remove both March and February 2013 data file. The format of how AWStats save its data is awstatsMMYYYY.[site-domain].txt. With that being said, you need to remove awstats032013.gix.my.txt and awstats022013.gix.my.txt.

This is what every forum and guide didn't mention based on our research - you will need to create an empty awstatsMMYYYY.[site-domain].txt file of the particular month. Otherwise AWStats will report that the older logs that you processed are old records and will not be added to your statistics database.

Finally, run the following command:

perl /var/www/awstats/awstats.pl -config=gix.my -configdir=/etc/awstats -LogFile=/var/logs/httpd/gix.my.log -update

Where:

  • /var/www/awstats/awstats.pl is the location of your awstats.pl file.
  • -config Usually it's your site domain name.
  • -configdir The directory that stores the AWStats config files. Usually it's /etc/awstats.
  • -LogFile The location of the log file that contains the old and current logs.

Once the process is completed, you should get the following line:

Found 0 old records
Found 302931 new qualified records.

If you have new qualified records, means you are doing it correctly to process the old log files. To view the updated statistics, visit your AWStats HTML page. If you still see the same result, you might want to try to clear your cache and refresh the page again.

Published on 21 March 2013 - 7:22am