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


Enter Your Query:
Use '%' for wildcards and quotes for "exact phrases"


Top Level » Apache Related Information

I need awstats to rebuild the static html pages for previous monthsLast Modified: May 21, 2014, 5:11 pm
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 <MM> <YY>";
         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


2003 JBMC Software, Suite 173  3-11 Bellerose Drive, St Albert, AB  T8N 1P7  Canada.  Mon-Fri 9AM-5PM MST