I have a black-box system that periodically updates a single-line "flag" file. This single-line file takes, over the course of the system's life various different values, corresponding to the states of an FSM.
E.g. like "downloading", "validating", "posting", etc. At any given point in time the value is different so the software must be opening the "flag" file, truncating it, and writing the new single-line value.
How can I maintain a log of the succession of different values? I was thinking something like
tail -f but with the ability to record the different values and with a way that's guaranteed not to mess with the file system when the software is updating of those values. A simple
tail -f fails with "file truncated" after some time.