Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

suggested feature..

1 view
Skip to first unread message

Colin Campbell

unread,
Feb 25, 2000, 3:00:00 AM2/25/00
to Martin Brooks
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


Michael Buchau

unread,
Feb 25, 2000, 3:00:00 AM2/25/00
to Martin Brooks
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?

No need to hack squid for that one. Assuming that you have set
"logfile_rotate 0" in squid.conf, this little script should do the
trick:

#! /bin/sh
LOGDIR=/var/squid/logs
LOGFILES="access.log cache.log"
datestr=`date '+%Y%m%d'`

for f in $LOGFILES
do
mv $LOGDIR/$f $LOGDIR/$f-$datestr
done
squid -k rotate
for f in $LOGFILES
do
gzip $LOGDIR/$f-$datestr
done


--
-----------------------------------------------------------------------
Michael Buchau <Michael...@Erlangen.Netsurf.DE> Erlangen, Germany
-----------------------------------------------------------------------


Aleksandr Konstantinov

unread,
Feb 25, 2000, 3:00:00 AM2/25/00
to squid...@ircache.net
Hello

There is nice utility called newsyslog. You just need
to patch it to copy/truncate the log instead of moving it
and squid is happy.

A.K.

newsyslog.diff

Miquel van Smoorenburg

unread,
Feb 26, 2000, 3:00:00 AM2/26/00
to squid...@ircache.net
In article <cistron.Pine.BSF.4.10.10...@phaser.telstra.net>,
cougar <cou...@telstra.net> wrote:
>Not meaning to beat up on your code, but newbies beware ...
>
>It's probably not wise to go moving files around while the Squid process
>is still using them (your first loop).

If you are using Windows, then probably not.

Under Unix, this is standard procedure.

Mike.
--
"dhbgr zr ba guvf bar - biretnna bc Rkpunatr vf rra jvwf orfyhvg" -- ZnepbU.
(punatrq gb ebg13 nsgre frireny frevbhfyl fbhaqvat guerngf).
--
The From: and Reply-To: addresses are internal news2mail gateway addresses.
Reply to the list or to miq...@cistron.nl (Miquel van Smoorenburg)


Henrik Nordstrom

unread,
Mar 5, 2000, 3:00:00 AM3/5/00
to Martin Brooks
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?

There already exists several tools for maintaining log files. One good
example of a log rotating framework with all functionality you will ever
need is logrotate from RedHat.

--
Henrik Nordstrom
Squid hacker


0 new messages