I was watching a log file (logfile.log) with tail -f
, and after a few minutes, the following message was written to the file:
tail: logfile.log: file truncated
I've never seen that before and I'm wonder why it happened, and how I can prevent it. The file is being written to by root (via a cronjob), and was created by another user.
It also seems that the cronjob is actually overwriting the logfile each time. I guess that this is probably the reason for the message I was seeing.
Edit Here's what the cronjob looks like:
* * * * * /usr/local/bin/ruby /home/web/script.rb > >/home/web/logfile.log 2>&1
Best Answer
I dont know if its just a typo.. but shouldnt it be
..../script.rb >> /home/web/logfile.log
for it to propertly append? Your code seems to have a space between the double angle bracketI tried it just now on bash in mac, it prompted an error, perhaps some shells may just ignore the second angle arrow in this case