#!/bin/zsh # script to generate the end of month stats for web sites. # it then gzips and archives the access log in /www/httpd/logs/archive. # should be run on the 1st of each month at 12:01am # usage: genstats should be run by cron. # barry caplin 2/29/96 mon=$(/bin/date +%m) year=$(/bin/date +%y) ((mon = $mon-1)) if ((mon==0)) then mon=12 if ((year > 0)) then ((year = $year-1)) else year=0 fi fi # to add a site add a site/dir/email entry for site in site1.com site2.com siten.com do case $site in "site1.com") dir="" email="";; "site2.com") dir="" email="";; "siten.com") dir="" email="";; esac # end of change area /www/httpd/cgi-bin/getstats -N -S http://www.$site -dr /www/$dir/htdocs \ -l /www/$dir/logs/access_log -c -sd "$mon/[1-31]/$year"|\ /bin/mail -s "Genstats for $site for $mon/$year" -b bc $email done cd /www/httpd/logs adate=$mon$year for file in $(/bin/ls access* agent* error* refer*) do afile=$file$adate /bin/cp /www/httpd/logs/$file /www/httpd/logs/archive/$afile /usr/bin/cat /dev/null > /www/httpd/logs/$file /bin/gzip /www/httpd/logs/archive/$afile done