Date: Mon, 21 Feb 2011 18:47:53 -0800 From: Doug Barton <dougb@dougbarton.us> To: freebsd-hackers@FreeBSD.org Subject: Problem with etc/periodic/daily/310.accounting Message-ID: <4D6323D9.5090500@dougbarton.us>
next in thread | raw e-mail | index | archive | help
This is a multi-part message in MIME format. --------------000906090401000304050905 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit 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 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 -- Nothin' ever doesn't change, but nothin' changes much. -- OK Go Breadth of IT experience, and depth of knowledge in the DNS. Yours for the right price. :) http://SupersetSolutions.com/ --------------000906090401000304050905 Content-Type: text/plain; name="310.accounting.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="310.accounting.diff" Index: 310.accounting =================================================================== --- 310.accounting (revision 218864) +++ 310.accounting (working copy) @@ -41,13 +41,15 @@ m=$n n=$(($n - 1)) done - cp -pf acct acct.0 || rc=3 - sa -s $daily_accounting_flags || rc=3 + mv acct acct.0 || rc=3 + case "$daily_accounting_compress" in [Yy][Ee][Ss]) - gzip -f acct.0 || rc=3;; + gzip --keep -f acct.0 || rc=3;; esac + + sa -s $daily_accounting_flags acct.0 && unlink acct.0 || rc=3 fi;; *) rc=0;; --------------000906090401000304050905--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4D6323D9.5090500>