From owner-freebsd-questions@FreeBSD.ORG Wed Jan 12 19:58:07 2011 Return-Path: Delivered-To: questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9431C1065672 for ; Wed, 12 Jan 2011 19:58:07 +0000 (UTC) (envelope-from freebsd@edvax.de) Received: from mx02.qsc.de (mx02.qsc.de [213.148.130.14]) by mx1.freebsd.org (Postfix) with ESMTP id 53ABC8FC0A for ; Wed, 12 Jan 2011 19:58:06 +0000 (UTC) Received: from r55.edvax.de (port-92-195-143-131.dynamic.qsc.de [92.195.143.131]) by mx02.qsc.de (Postfix) with ESMTP id 2B3861E302; Wed, 12 Jan 2011 20:58:06 +0100 (CET) Received: from r55.edvax.de (localhost [127.0.0.1]) by r55.edvax.de (8.14.2/8.14.2) with SMTP id p0CJw4T5001581; Wed, 12 Jan 2011 20:58:04 +0100 (CET) (envelope-from freebsd@edvax.de) Date: Wed, 12 Jan 2011 20:58:04 +0100 From: Polytropon To: Redd Vinylene Message-Id: <20110112205804.3ec42ec8.freebsd@edvax.de> In-Reply-To: References: <4D2DFEAE.9060403@bah.homeip.net> Organization: EDVAX X-Mailer: Sylpheed 2.4.7 (GTK+ 2.12.1; i386-portbld-freebsd7.0) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: questions , Bernt Hansson Subject: Re: Simple command to reset / clear all logs? X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Polytropon List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Jan 2011 19:58:07 -0000 On Wed, 12 Jan 2011 20:50:04 +0100, Redd Vinylene wrote: > Will the logs automatically create themselves? Usually not, but it depends on the logging mechanism. If a program continuously re-opens the file (after closing it) in APPEND mode, it should be created if non-existent. But if the program keeps the file open and just writes to it, it can cause trouble. Good programs check the return code of the writing operation and signal an error. Bad programs don't do that, they just keep writing to nowhere. :-) > I mean, I picture I have to > manually touch a lotta them in order to avoid "cannot find" error messages? This should be the safest method for most purposes. But as I mentioned, just trim down the files to zero length, so they keep present, and all writing processes (re-opening APPEND or contunuously keep writing) shouldn't notice that. # for FILE in /var/log/*; do cat /dev/null > ${FILE}; done That would be better than my first suggestion. You can exchange the part "/var/log/*" for any `find ...` command that specifies the intended target(s) of your operation better than the builtin shell expansion of the * expression. -- Polytropon Magdeburg, Germany Happy FreeBSD user since 4.0 Andra moi ennepe, Mousa, ...