To generate a weekly and monthly reports, i use this sarg-main file : ---- /usr/sbin/sarg-maint ---- #! /bin/bash set -e
if [ -e /etc/environment ]; then . /etc/environment fi export LANG test -f /usr/bin/sarg || exit 0 #TODO: clean all daily reports they are too old #All the day a daily report #Get yesterdays date YESTERDAY=$(date --date "1 day ago" +%d/%m/%Y) /usr/bin/sarg -d $YESTERDAY-$YESTERDAY >/dev/null # uncomment this and replace the email address to have daily reports # mailed to you #/usr/bin/sarg -d $YESTERDAY-$YESTERDAY -e [EMAIL PROTECTED] # On first day of month, a monthly report if [ `date +%d` == "01" ]; then BIGLOG=`mktemp` MONTH=`date --date="last month" +%m/%Y` PERIOD=01/$MONTH-31/$MONTH for LOGFILE in `ls -v /var/log/squid/access.log*`; do if [ `file -b $LOGFILE|grep -c gzip` -eq 1 ]; then zcat $LOGFILE>>$BIGLOG else cat $LOGFILE>>$BIGLOG fi done /usr/bin/sarg -d $PERIOD -l $BIGLOG rm $BIGLOG fi #On monday the weekly report if [ `date +%u` == "1" ]; then BIGLOG=`mktemp` FIRST=`date --date="last week" +%d/%m/%Y` LAST=`date --date="last day" +%d/%m/%Y` PERIOD=$FIRST-$LAST for LOGFILE in `ls -v /var/log/squid/access.log*`; do if [ `file -b $LOGFILE|grep -c gzip` -eq 1 ]; then zcat $LOGFILE>>$BIGLOG else cat $LOGFILE>>$BIGLOG fi done /usr/bin/sarg -d $PERIOD -l $BIGLOG rm $BIGLOG fi exit 0 ---- /usr/sbin/sarg-maint ---- -- Thomas Clavier http://www.tcweb.org Lille Sans Fil http://www.lillesansfil.org +33 (0)6 20 81 81 30 -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]