tail -F

I would like to follow an error log as errors are written. The GNU tail command support a --follow option that outputs data as a file grows. There's also a --retry option that will keep trying to access a file even if it becomes inaccessible (e.g., during log rotation). The -F option is equivalent to --follow=name --retry

The tail command can be run in the background to passively monitor error logs, e.g.,

# tail -n0 -F error.log &
[2] 23906
#
... go on working in the shell
# [Thu Jun 30 00:33:28 2011] [error] File does not exist: ...
#
This entry was posted in shell tips. Bookmark the permalink.