From owner-freebsd-questions@FreeBSD.ORG Sun Aug 4 23:28:36 2013 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id F3EB3D4A for ; Sun, 4 Aug 2013 23:28:35 +0000 (UTC) (envelope-from frank2@fjl.co.uk) Received: from bs1.fjl.org.uk (bs1.fjl.org.uk [84.45.41.196]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id A40682E66 for ; Sun, 4 Aug 2013 23:28:34 +0000 (UTC) Received: from [192.168.1.35] (mux.fjl.org.uk [62.3.120.246]) (authenticated bits=0) by bs1.fjl.org.uk (8.14.4/8.14.4) with ESMTP id r74NSW3A072840 (version=TLSv1/SSLv3 cipher=DHE-DSS-CAMELLIA256-SHA bits=256 verify=NO) for ; Mon, 5 Aug 2013 00:28:33 +0100 (BST) (envelope-from frank2@fjl.co.uk) Message-ID: <51FEE3A1.4080301@fjl.co.uk> Date: Mon, 05 Aug 2013 00:28:33 +0100 From: Frank Leonhardt User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20130620 Thunderbird/17.0.7 MIME-Version: 1.0 To: freebsd-questions@freebsd.org Subject: Re: Archiving a log file References: <51FD8E19.90403@fjl.co.uk> <37485629-94BD-48EF-B7A7-9ED4C5B9A6E5@olivent.com> <51FE32D3.3000707@fjl.co.uk> <5DF8D376-34BF-4748-8371-C616E7FEC2A1@elde.net> In-Reply-To: <5DF8D376-34BF-4748-8371-C616E7FEC2A1@elde.net> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Content-Filtered-By: Mailman/MimeDel 2.1.14 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 23:28:36 -0000 On 04/08/2013 14:38, Terje Elde wrote: > On 4. aug. 2013, at 12:54, Frank Leonhardt wrote: >> The program writing the log is actually called flubnutz and it doesn't play nice with newsyslog, reopen handles on a signal or anything else > Then you're out of luck for normal rotation. No matter if you rename the file, or even delete it, it'll keep writing to the same file (the moved file, not the same filename). > > I suppose your options are to either restart it to have it reopen the file, or if that's not desirable for whatever reason, look see if it'll play nice if you put a named pipe where the logfile is supposed to be. Then you can handle data as you'd like from the pipe. > > Terje > Thanks. The consensus seems to be that there is no way to do this other than "start from a different place". It'd be difficult for the kernel to trim a file from the start unless it was on a block boundary, so it's not implemented and explains the numerous work arounds for dealing with logs (fifo to log manager, signalling an application to reopen logs because file has changed and so on). So I will carry on using my original bodge, happy in the knowledge that it may not be perfect, but there's no better method known to exist unless I want to implement a better truncate() in the kernel. Regards, Frank.