I have noticed recently that sometimes tail -f <logfile>
will stop updating to the screen.
Doing a Ctrl>-C and restarting the tail
works fine, though. And I checked to make sure the logfile isn't being rotated midstream (which can make tail
lose its mind).
What would cause this? I'm running RHEL 5.2 x64.
Try using:
tail --follow=name <logfile>
And see if that works better. You don't have to worry about it being rotated out from under you.
Any pattern to it stopping? Certain length of time? Certain time of day?
Try wrapping your tail command with
strace
if you have it:Then just for crazy recursive kicks you can tail the strace output (doesnt' matter if that breaks because its going out to a file):
Mine looks like:
The -t switches on the time and -T switches on time spent in calls.
Hit return 4 or 5 times to make a bit of vertical space, then wait for it to stop tailing. Hopefully there will be some clues in the output.
Given that both problematic logfiles are written by different components of the same application, I wonder if it's not some part of the logging code for that application that's causing the problem. I propose two tests to get a better idea of what's going on:
Note the inode of the logfile (
ls -i logfile
) prior to starting the tail, and once the tail fails, check it again. If the inode has changed, then the logger is rewriting the entire logfile, which would break tail's connection.Note the last line before tail stops working, and then visit the file and find the first log entry after that line. Do this 3-5 times if possible. If it's a problem with the program doing the logging, the part of the program that wrote the log entry immediately after you see tail break is most likely responsible. If that log entry is always the same, or if it comes from the same component of the program, you may have enough data to submit a problem report to the application vendor.
Good luck.
Having the same problem here.
Problem was, that the file i'm watching was mounted from a different machine. The change notify was not propagated through the mount.
Solution was to use tail on the original machine.