I have some logs being generated using a timed rotating file logger. This logs to a file called tool.log
, and at midnight, moves this to tool.log.<date>
and starts a new tool.log
.
I have a tail -f tool.log
running on the machine to keep an eye on the logs, but at midnight, when tool.log
is renamed to tool.log.<date>
, tail
continues to watch the renamed file.
What I'm hoping for is a tool that is similar to tail
, but will continue to monitor the file named tool.log
, rather than following the inode.
Does something like this exist? If not, I can write my own in Python for this purpose.
Best Answer
Some implementations of
tail
have an option for this; here's the description from the man page for GNU tail:As this option isn't specified by POSIX, you can't depend on it everywhere. Some known implementations:
-F
as described above-F
option with the same effect-f
is enough (if the file is replaced (i.e., the inode number changes), tail will reopen the file and continue)-F
is available in recent versions, but must be compiled withENABLE_FEATURE_FANCY_TAIL
(it's not compiled-in by default)