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

Re: How to properly empty log files



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).

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

Chris


Reply to: