Use [tail -F] (capital F) instead of [tail -f] when tailing log files.
Key Differences
tail -ffollows the file descriptor - stops working if file is deleted/rotatedtail -Ffollows the file path - automatically reconnects when file is recreated
Why This Matters for Logs
Log rotation tools (logrotate, etc.) commonly:
- Move
app.logtoapp.log.1 - Create a new empty
app.log - Signal the app to start writing to the new file
With tail -f: You'd be stuck watching the old rotated file
With tail -F: Automatically switches to the new file
Bottom Line
# This stops working after log rotation
tail -f /var/log/app.log
# This keeps working through log rotations
tail -F /var/log/app.log
Always use tail -F for production log monitoring.
Backlinks