[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: How to properly empty log files



On Fri, Oct 17, 2008 at 09:44:43AM +0100, Chris Davies wrote:
> François Cerbelle <francois@cerbelle.net> wrote:
> > you can "truncate" the file with the folowing bash line :
> > > /var/log/mail.err
> 
> > or the following portable line :
> > echo > /var/log/mail.err
> 
> Neither of those will work in this instance, as the file is held open
> for writing. On the next write, the data will be written into the file
> at the same place as if you hadn't truncated it (all the preceding data
> will appear to be NULLs).

Are you sure? The above method works fine for me.

> 
> Incidentally, "echo > x" writes a newline to the file, so it's not zero
> length. You might like to use ": > x" instead.

Right.

-- 
Tzafrir Cohen         | tzafrir@jabber.org | VIM is
http://tzafrir.org.il |                    | a Mutt's
tzafrir@cohens.org.il |                    |  best
ICQ# 16849754         |                    | friend


Reply to: