Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 12 Jan 2011 20:58:04 +0100
From:      Polytropon <freebsd@edvax.de>
To:        Redd Vinylene <reddvinylene@gmail.com>
Cc:        questions <questions@freebsd.org>, Bernt Hansson <bernt@bah.homeip.net>
Subject:   Re: Simple command to reset / clear all logs?
Message-ID:  <20110112205804.3ec42ec8.freebsd@edvax.de>
In-Reply-To: <AANLkTi=bbT7d=FvFHFpWpZgXb_cHgNGaa_ZS%2BSdWxXua@mail.gmail.com>
References:  <AANLkTimMvTxsdRXhxzXwjdTDzQ5U7m7kzVc0orGwxM5U@mail.gmail.com> <4D2DFEAE.9060403@bah.homeip.net> <AANLkTi=bbT7d=FvFHFpWpZgXb_cHgNGaa_ZS%2BSdWxXua@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, 12 Jan 2011 20:50:04 +0100, Redd Vinylene <reddvinylene@gmail.com> 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, ...



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20110112205804.3ec42ec8.freebsd>