![](https://seccdn.libravatar.org/avatar/93cf6319a8961d144cf9d0dc09f5e319.jpg?s=120&d=mm&r=g)
It's good to see that mentioned in public. I used to just delete log files and let them get re-created, and sometimes suffered odd glitches that probably originated with that practice... Somebody finally pointed out the method of cat-ing /dev/null over the contents of a live logfile, and I now have slightly fewer odd glitches... slightly... While we're on the topic, a UNIX guru at a previous company had all kinds of scripts and cron jobs that checked file sizes of logfiles and either waved flags at the operator or else regularly copied current contents to a backup location and then zeroed out the contents of live files (much as you suggest). Are there some canned utilities that do this stuff in Linux, or does everybody re-invent the wheel on their own system? /kevin On Thu, 2002-04-04 at 08:23, Dave Smith wrote:
On Thu, Apr 04, 2002 at 03:10:01PM +0200, php@nickselby.com wrote:
Hmmm. When I did cat /dev/null it started scrolling for about a week (actually about two hours) but I got the impression it was COPYING the file to /dev/null not moving the cvontents there. Was that just plain wrong of me?
You remembered the redirection arrow?
cat /dev/null > /var/log/messages
^ | This is important
what it's doing is copying /dev/null (which is a zero-length file) to overwrite /var/log/messages.
If you miss out the arrow, then you're just asking cat to display the contents of /dev/null and /var/log/messages on the screen. I'm not surprised that it scrolled for ages.