Add to Favourites Add to Favourites    Print this Article Print this Article

I need awstats to rebuild the static html pages for previous months

Assuming the data for the require months does exist in here:

/home/username/domains/domain.com/awstats/.data

you should be able to re-generate your static html pages for those months.  The script below can do it for you:

#!/bin/sh
if [ "$#" -eq 0 ]; then
         echo "Usage:";
         echo "    $0          exit 1;
fi

month=$1
short_year=$2
full_year=20${short_year}

for u in `ls /usr/local/directadmin/data/users`; do
{
         for d in `cat /usr/local/directadmin/data/users/$u/domains.list`; do
         {
                   echo "";
                   echo "$u: $d: $month $full_year";
                   DATA=/home/$u/domains/$d/awstats/.data/awstats${month}${full_year}.${d}.txt
                   if [ ! -s $DATA ]; then
                             echo "Cannot find $DATA for $month $full_year. Skipping.";
                             continue;
                   fi

                   /usr/bin/perl /usr/local/awstats/tools/awstats_buildstaticpages.pl
                       -config=$d -configdir=/home/$u/domains/$d/awstats/.data -update
                       -diricons=icon -awstatsprog=/usr/local/awstats/cgi-bin/awstats.pl
                       -dir=/home/$u/domains/$d/awstats -builddate=${short_year}${month}
                       -year=$full_year -month=$month

                   echo "";
         }
         done;
}
done;
exit 0;

save this to a script, say old_awstats.sh, and set it to 755.

Run it for each month, for example, April (month 04) 2014:

./old_awstats.sh 04 14



Was this answer helpful?

Also Read