Re: suggested feature..

From: Colin Campbell <sgcccdc@dont-contact.us>
Date: Fri, 25 Feb 2000 10:28:05 +1000 (EST)

Hi,

On Fri, 25 Feb 2000, cougar wrote:

> On Thu, 24 Feb 2000, Michael Buchau wrote:
>
> > 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
>
> 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).

There's no problem here since the files are in the same directory and the
"mv" is merely a rename - perfectly safe since squid can keep the file
open (same inode). Where you get into trouble is when you move files
between filesystems. That IS a no-no.

>
> It _would_ be wise to signal the Squid process to rotate it's logs
> _before_ any further manipulation via OS commands.

No use if you "log_rotate 0"

>
> Also, in certain cases, admins may be rotating more frequently than once
> per day, so you'll have multiple <access|cache>.log.<n> files laying
> around.

That's why the script I use uses

date "+%Y%m%d.%H%M%S"

Unless you rotate twice in the same second, it's safe :-)

Colin
Received on Thu Feb 24 2000 - 17:35:56 MST

This archive was generated by hypermail pre-2.1.9 : Tue Dec 09 2003 - 16:51:33 MST