#!/bin/sh # Dinko Korunic, 2006. set -e # use timestamps TS=`date +%Y-%m-wk%V` # workdir cd /usr/local/squid/logs # down with the service svc -d /service/squid # wait for it to finish while pidof squid >/dev/null 2>&1; do sleep 11s done # move logs to a working copy mv -f squid-access.log squid-access.log.$TS # enable the empty log touch squid-access.log chown squid: squid-access.log # up with the service svc -u /service/squid # split the logs gawk '{ print $0 >> "squid-log-" strftime("%Y-%m-wk%V", $1) }' < squid-access.log.$TS # delete the working copy rm -f squid-access.log.$TS # and parse the last file through calamaris calamaris -a < squid-log-$TS > squid-analysed-$TS.txt # end true