From owner-freebsd-questions@FreeBSD.ORG Sun Aug 4 01:13:10 2013 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 9315DA2F for ; Sun, 4 Aug 2013 01:13:10 +0000 (UTC) (envelope-from mikel.king@gmail.com) Received: from mail-qe0-x231.google.com (mail-qe0-x231.google.com [IPv6:2607:f8b0:400d:c02::231]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 53BCC24FF for ; Sun, 4 Aug 2013 01:13:10 +0000 (UTC) Received: by mail-qe0-f49.google.com with SMTP id 1so1077190qec.36 for ; Sat, 03 Aug 2013 18:13:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=references:mime-version:in-reply-to:content-type :content-transfer-encoding:message-id:cc:x-mailer:from:subject:date :to; bh=qSWiRWUeBEMCt3qZXNt6jU3w1t5BYD9oMlu8UmOeEJU=; b=SoSUOuuo6/dnLKhTe2qOrqQ4vlDDpzNy9/f65uE2sLe8G6Q2Os0IDNjdOA4OaKejMI BT34nTw6asFM4+BT4LdxH09XEC6bPiVjTQJAjgvldXj/1gfq5IinCUlykwM3Kx+ESgXA GERD+kkJn7UNbnV4HvyAcOe95S7z6GKy50TDt3wNssww+7NYP5aubxviusvflJELtRRi ML6wVr85xc54F82lgzCnCClHbUWhm9C3qyKOS31wU0DB+LjBlOrZOZR0M7g9yM/Ttl0o F3uIh78E+uL7zcw8UTz+Ga/kY2RgelTiDPffLCKC/xGB2yttrUkBGAYvSPsNiFMheQj5 gA1g== X-Received: by 10.224.64.202 with SMTP id f10mr20297698qai.6.1375578789403; Sat, 03 Aug 2013 18:13:09 -0700 (PDT) Received: from [172.16.1.218] (mail.olivent.com. [75.99.82.91]) by mx.google.com with ESMTPSA id nh4sm230023qeb.6.2013.08.03.18.13.07 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 03 Aug 2013 18:13:08 -0700 (PDT) References: <51FD8E19.90403@fjl.co.uk> Mime-Version: 1.0 (1.0) In-Reply-To: <51FD8E19.90403@fjl.co.uk> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Message-Id: <76073A9A-CE2D-4ACF-89B5-AAE7E580A8E6@gmail.com> X-Mailer: iPhone Mail (10B350) From: mikel king Subject: Re: Archiving a log file Date: Sat, 3 Aug 2013 21:13:06 -0400 To: Frank Leonhardt Cc: "freebsd-questions@freebsd.org" X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 04 Aug 2013 01:13:10 -0000 Do you have logger installed? You coupled pipe your CustomLog into logger wh= ich will facilitate Apache writing to syslog, in lieu of directly writing th= e file. After some tweaking this should let you use the systems standard log= rotation schema.=20 Something like: CustomLog "| logger -t httpd -p local.info" Cheers, m On Aug 3, 2013, at 19:11, Frank Leonhardt wrote: > The answer isn't (AFAIK) newsyslog >=20 > As a one-off, I need to archive an old log file - say httpd-access.log - w= hile its still open. I don't want this to happen automatically and I don't w= ant to set up newsyslog or anything like that. And I really don't want to me= ss about with signals to whatever is writing to the file, even assuming the w= riter could respond to them. I can't just rename the file as it's open for w= riting, and there would also be a good chance that something will be added t= o the file while it's being compressed. >=20 > What I actually do is: >=20 > cp httpd-access.log httpd-access.log-03-Aug-13 && :> httpd-access.log && b= zip2 httpd-access.log-03-Aug-13 >=20 > Data might be lost here as something may be added between the cp being com= pleted and the file being truncated. It's not the end of the world if this h= appens, but is there a better way? I could always shut down Apache for the d= uration, but I don't want to do that either, so in this case I'm happy to ta= ke the risk (it's not like I'm likely to miss anything that important). >=20 > I don't know if this can be relied on as a POSIX thing, but the cp command= simply(!) issues read() and write() calls until read() fails to get any mor= e bytes, so if data is being appended to the file after cp is started it'll s= till be copied. Therefore the window where stuff could be written after the c= opy but before the truncation is shortened, but extant. >=20 > So what's the magic utility I don't know about? >=20 > Thanks, Frank. >=20 >=20 > _______________________________________________ > freebsd-questions@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-questions > To unsubscribe, send any mail to "freebsd-questions-unsubscribe@freebsd.or= g"