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

Re: /var full



Am Mittwoch, 30. Januar 2013 schrieb David Guntner:
> Bob Proulx grabbed a keyboard and wrote:
> > In the future instead of removing a file that you want to be freed
> > immediately consider truncating it instead.  By truncating the file it
> > does not matter if there are other handles to it.  The filesystem will
> > immediately free the storage associated with it.  The running syslogd
> > in this case will continue to write to the same file handle.
> > 
> >   root@example:~# : >/var/log/syslog
> > 
> > I use ":" (aka "true") because historically a file redirection without
> > a command associated with it was not guaranteed portable.  Probably
> > doesn't matter today.  Just one of my quirks now.
> 
> Didn't know about that one (or that : by itself is a reference to TRUE).
>  Good info!  When I've needed to truncate a file, I've always just done
> a:
> 
> cp /dev/null {file-to-be-truncated}
> 
> which works nicely. :-)

There is also a truncate command where you can give a desired size.

But it cuts from the end of the file, not from the beginning which would be 
more suitable for log files.

-- 
Martin 'Helios' Steigerwald - http://www.Lichtvoll.de
GPG: 03B0 0D6C 0040 0710 4AFA  B82F 991B EAAC A599 84C7


Reply to: