Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 20 May 1999 01:51:24 -0500 (CDT)
From:      Jeff Lynch <jeff@mercury.jorsm.com>
To:        freebsd-isp@FreeBSD.ORG
Subject:   Re: Web Statistics break up program.
Message-ID:  <Pine.BSF.3.95q.990520013449.22143I-100000@mercury.jorsm.com>
In-Reply-To: <Pine.GSO.3.96.990518195705.24618B-100000@roble2.roble.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, 18 May 1999, Roger Marquis wrote:

> > > This will create an archived logfile (http.site.May_1999) and erase
> > > the original without needing to kill -1 the httpd.
> > > 
> > > 	#!/bin/sh -
> > > 	LOGDIR=/var/log
> > > 	ARCDIR=/var/log/oldlogs
> > > 	DAY=`date | awk '{ OFS="_" ;print $2,$6}' `
> > > 	for log in $LOGDIR/http* ; do
> > > 		cp $log $ARCDIR/${log}.${DAY}
> > > 		chmod 440 $ARCDIR/${log}.${DAY}
> > > 		cp /dev/null $log
> > > 	done
> > 
> > Egads!!
> > That's a pretty vicious race condition there, you'll lose records on busy
> > servers.
> 
> In theory perhaps, in reality it doesn't.  I've never seen this algorithm 
> fail, even when used on log files that grow by several megabytes per day.
> 
> --
> Roger Marquis

Briefly looking at the src for cp(1), it looks like you're both right. cp
stats and then mmaps the file at that instant if < 8MB (extended to next
multiple of page size) so appendages beyond that would be lost. For
greater than 8MB it while(read)'s until EOF, no race.

--jeff

============================================================================ 
Jeffrey A. Lynch		| JORSM Internet, Regional Internet Services
email: jeff@jorsm.com		| 7 Area Codes in Chicagoland and NW Indiana
Voice: (219)322-2180		| 100Mbps+ Connectivity, 56K-DS3, V.90, ISDN
Autoresponse: info@jorsm.com	| Quality Service, Affordable Prices
http://www.jorsm.com		| Serving Gov, Biz, Indivds Since 1995




To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-isp" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.3.95q.990520013449.22143I-100000>