Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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
share|improve this question
2  
It's around midnight on the east coast. Do you have any log rotation jobs running? –  jgoldschrafe Oct 5 '12 at 4:56
    
Could be, but this logfile wouldn't be part of that (unless somehow the log rotation jobs are picking up every *.log file on the system?) Besides, our servers are in PST. –  bricker Oct 5 '12 at 5:00
1  
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 bracket –  Karthik T Oct 5 '12 at 5:16
    
@KarthikT Hey that was it! Post it as an answer and I'll accept it :) –  bricker Oct 5 '12 at 5:20
1  
For the benefit of anyone else reading this question in the future who is seeing that error, but you know that the log file is being rotated/purged, you can avoid the error above using tail -F instead of tail -f –  Bryan Oct 5 '12 at 7:22

1 Answer 1

up vote 4 down vote accepted

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 bracket

I 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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.