Hi,
On Thu, 24 Feb 2000, Martin Brooks wrote:
> Just a thought for a future version of Squid. On the log rotation
> front, how about a facility to time/date stamp and compress the log
> file?
>
Here's what I do
----------------
In squid.conf:
logfile_rotate 0
From cron I run the following script:
-------------------------------------------------------------
#!/bin/sh
#
# $Id: squid.rotate,v 1.5 1999/10/14 01:59:46 root Exp $
prog=`basename $0`
ARCHDIR=/var/log/archive/squid
LOGDIR=/var/log/squid
LOGS="access.log cache.log store.log"
cd $LOGDIR
# timestamp the logs
now=`date "+%Y%m%d.%H%M%S"`
if [ -z "$now" ]; then
# highly unlikely but paranoia never hurt anyone
echo "$prog: cannot get date - exiting"
exit 1
fi
for log in $LOGS; do
if [ -f $log ]; then
mv $log $log.$now
fi
done
# get squid to rotate the logs
/squid/bin/squid -k rotate
# if everything worked, move the logfiles to the archive dir
sleep 30 # let squid catch up
for log in $LOGS; do
if [ -f $log ]; then # the proper log exists
mv $log.$now $ARCHDIR
fi
done
# make 'em smaller
cd $ARCHDIR
for log in $LOGS; do
if [ -f $log.$now ]; then # the proper log exists
gzip $log.$now
fi
done
exit 0
-------------------------------------------------------------
By putting the date AND time on the logs, it allows multiple rotations in
one day.
Colin
Received on Thu Feb 24 2000 - 15:49:23 MST
This archive was generated by hypermail pre-2.1.9 : Tue Dec 09 2003 - 16:51:33 MST