Date: Sat, 3 Aug 2013 21:13:06 -0400 From: mikel king <mikel.king@gmail.com> To: Frank Leonhardt <freebsd-doc@fjl.co.uk> Cc: "freebsd-questions@freebsd.org" <freebsd-questions@freebsd.org> Subject: Re: Archiving a log file Message-ID: <76073A9A-CE2D-4ACF-89B5-AAE7E580A8E6@gmail.com> In-Reply-To: <51FD8E19.90403@fjl.co.uk> References: <51FD8E19.90403@fjl.co.uk>
next in thread | previous in thread | raw e-mail | index | archive | help
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 <freebsd-doc@fjl.co.uk> 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"
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?76073A9A-CE2D-4ACF-89B5-AAE7E580A8E6>