Tail Command – Fixing ‘tail -s N’ Not Sleeping for N Seconds

tail

The manual for GNU tail says

-s, --sleep-interval=N

with -f, sleep for approximately N seconds (default 1.0) between iterations; with inotify and --pid=P, check process P at least once every N seconds

But when I write tail --sleep-interval=10 -F file_name
it does not sleep for 10 seconds, it updates it right away. Am I understanding it wrong, or using it wrong?

Thanks for helping

Best Answer

The full manual describes -s as

Change the number of seconds to wait between iterations (the default is 1.0). During one iteration, every specified file is checked to see if it has changed size. When tail uses inotify, this polling-related option is usually ignored. However, if you also specify --pid=p, tail checks whether process p is alive at least every number seconds. The number must be non-negative and can be a floating-point number in either the current or the C locale. See Floating point.

Your system presumably is inotify-capable, so tail will use that instead of polling, and since you’re not following a pid, the -s option has no effect. You can disable inotify with the undocumented ---disable-inotify option (with three dashes), which will result in tail sleeping as expected (thanks to Stéphane Chazelas for the suggestion!).

Related Question