From owner-freebsd-hackers@FreeBSD.ORG Tue Feb 22 08:46:40 2011 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id ED91F1065670 for ; Tue, 22 Feb 2011 08:46:40 +0000 (UTC) (envelope-from danger@FreeBSD.org) Received: from services.syscare.sk (services.syscare.sk [188.40.39.36]) by mx1.freebsd.org (Postfix) with ESMTP id A9ADF8FC16 for ; Tue, 22 Feb 2011 08:46:40 +0000 (UTC) Received: from services.syscare.sk (services [188.40.39.36]) by services.syscare.sk (Postfix) with ESMTP id 4330681F52 for ; Tue, 22 Feb 2011 09:31:33 +0100 (CET) X-Virus-Scanned: amavisd-new at rulez.sk Received: from services.syscare.sk ([188.40.39.36]) by services.syscare.sk (services.rulez.sk [188.40.39.36]) (amavisd-new, port 10024) with ESMTP id nufZ5MhK5TeM for ; Tue, 22 Feb 2011 09:31:31 +0100 (CET) Received: from danger-mbp.local (59576.ba.3pp.slovanet.sk [84.16.39.226]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: danger@rulez.sk) by services.syscare.sk (Postfix) with ESMTPSA id 3A65081F45 for ; Tue, 22 Feb 2011 09:31:31 +0100 (CET) Message-ID: <4D637462.7000807@FreeBSD.org> Date: Tue, 22 Feb 2011 09:31:30 +0100 From: Daniel Gerzo Organization: The FreeBSD Project User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2.15pre) Gecko/20110221 Lanikai/3.1.9pre MIME-Version: 1.0 To: freebsd-hackers@freebsd.org References: <4D6323D9.5090500@dougbarton.us> In-Reply-To: <4D6323D9.5090500@dougbarton.us> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: Problem with etc/periodic/daily/310.accounting X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 Feb 2011 08:46:41 -0000 On 22.2.2011 3:47, Doug Barton wrote: > I was looking over etc/periodic/daily/310.accounting on a system that is > very tight on space in /var, and I think that at minimum there is a > race, and at best there is a pretty serious inefficiency. > > Right now after rotating the old logs the script does this: > > cp -pf acct acct.0 || rc=3 > sa -s $daily_accounting_flags || rc=3 > > case "$daily_accounting_compress" in > [Yy][Ee][Ss]) > gzip -f acct.0 || rc=3;; > esac > > To start with, the cp is a problem on a space-constrained system > especially when the log is very large. However I think that doing it > this way also introduces a race where events that are logged between the > cp and the sa run are not backed up in acct.0. ITSM that the proper > procedure is: > > mv acct acct.0 || rc=3 I think you should at least `touch acct' here. > case "$daily_accounting_compress" in > [Yy][Ee][Ss]) > gzip --keep -f acct.0 || rc=3;; > esac > > sa -s $daily_accounting_flags acct.0 && unlink acct.0 || rc=3 > > Can anyone see why that would be wrong? If there is no objection, I'll > be committing the attached patch. > > > Doug -- S pozdravom / Best regards Daniel Gerzo, FreeBSD committer