Continuing to tail a file after it’s been rotated

I use xtail and tail quite a bit to debug problems. Sometimes when I’m up late at night troubleshooting issues, the log rotation jobs will kick off and my tail session will stop updating (tail will follow the file descriptor associated with the file by default, not the name of the file). Since this can make debugging an issue a bit confusing, I’ve made it a habit to alias tail to something like this:

$ alias tailer=”tail –follow=name –retry”

The “–follow=name” option will cause tail to follow the name of the file and not the file descriptor, and the “–retry” option will cause tail to try to re-open the file if it’s not accessible (log rotation events will cause the file to change). It’s become second nature to run tailer now, and I don’t get that “WTF?!?” moment at 2am now. ;)

3 thoughts on “Continuing to tail a file after it’s been rotated”

  1. @Rahul — yeah, it sure will. I’ve become so used to using “tailer” that I completely forgot about tail’s “-F” option. :) Thanks for the note!

Leave a Reply

Your email address will not be published. Required fields are marked *