I've got a symlink pointing to the "latest" directory, and I want to tail a file in the latest directory, even if the symlink changes to a newly created directory. I often use tail -F for files and it works fine as inotify tells tail when to reopen the file, but in this case, inotify doesn't notice the change so I expect tail to check again after 5 seconds of the second-latest file being unchanged. (5 seconds according to the tail manpage and the defaults for --sleep-interval=1.0 and --max-unchanged-stats=5.)

tail -F --max-unchanged-stats=1 -s 1 /tmp/latest/behaviour
ln -sfT /tmp/2019-02-14-10-15-12 /tmp/latest

How can I tail the file in the latest directory?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.