On a sidenote: I teach people to always use tail -F instead of tail -f. You won't see the difference that often. But when you do, you wish you had started with -F instead.
You'll see the difference when you are tailing that log file to see why the deamon crashes on restart (only to find that on restart it also rotates the logs buy deleting and re-creating: tail stops)
You'll also see the difference when you keep tail running (e.g. in screen) and on re-opening to find you have to restart it.
And mostly, you'll see this breaking when some script or tool uses tail to e.g. monitor something and have that script crash when the log is rotated (poorly).
I've used -F before but mostly use -f. Will -F close the file handle when the logs are rotated? Sometimes I leave a console open with -f running and the logs rotate but the disk space isn't reclaimed since there is still an open handle until I quit.
95
u/berkes Mar 30 '15
On a sidenote: I teach people to always use
tail -Finstead oftail -f. You won't see the difference that often. But when you do, you wish you had started with -F instead.-F same as --follow=name --retrytail(1).You'll see the difference when you are tailing that log file to see why the deamon crashes on restart (only to find that on restart it also rotates the logs buy deleting and re-creating: tail stops)
You'll also see the difference when you keep tail running (e.g. in screen) and on re-opening to find you have to restart it.
And mostly, you'll see this breaking when some script or tool uses tail to e.g. monitor something and have that script crash when the log is rotated (poorly).
(edit: inserted some blank lines for legibility)