cat /home/jsand/scripts/arc.sarg.sh # File : /home/jsand/scripts/arc.sarg.sh # Computer: 192.168.0.1 # Use : Archive sarg statistics older than 1 month # Created : 2009.01.28 # Author : Andrey v Strukov # Changes : none # SET VARS currmonth=`date -v+0m | awk '{print ($2)}'` destmonth=`date -v-1m | awk '{print ($2)}'` curryear=`date -v+0m | awk '{print ($6)}` destyear=`date -v-1m | awk '{print ($6)}` repdir='/usr/local/www/data-dist/sarg' dstdir='/home/jsand' adminemail=' jsand@ep.com ' reporttext='Internet statistic has been sucefully archieved. Please download archive file from your ftp 192.168.0.1. Cheers.' #echo BEGIN #echo Current month - $currmonth #echo Destination month - $destmonth #echo Current year - $curryear #echo Destination year - $destyear #echo #echo File $destyear$destmonth.tar will be created #echo Files "$repdir/*$destmonth*" will be archieved #echo Files "$repdir/*$destmonth*" will be removed # MAKE ARCHIVE tar -cvf $dstdir/$destyear$destmonth.tar $repdir/*$destmonth* # TEST ARCHIVE AND SELECT: MOVE+DELETE+REPORT OT WARNING if test -f $destyear$destmonth.tar then rm -Rf $repdir/*$destmonth* mv $repdir/$destyear$destmonth.tar $dstdir echo "$reporttext" | mail -s "ARCHIVE.REPORT" $adminemail else echo "WARNING ! INTERNET STATS ARCHIVE FILE NOT FOUND. Please check it manually." | mail -s WARNING $adminemail fi
|