↑↓ move Enter open Esc close

How to Follow a Log File Live in Linux

Follow new log entries with tail and handle log rotation correctly.

When debugging a running service, repeatedly reopening a log wastes time. `tail -f` keeps the file open and displays new lines as they arrive.

Step by step

1 Follow the file

$ tail -f app.log

Prints existing final lines and waits for new output.

2 Start with more context

$ tail -n 100 -f app.log

Shows the last 100 lines and then continues following.

3 Follow through rotation

$ tail -F app.log

The capital F keeps trying to reopen the pathname if the underlying file is replaced during log rotation.

4 Filter the stream

$ tail -f app.log | grep --line-buffered -i error

Shows only matching new lines while preserving immediate output.

Tips worth knowing

Frequently asked questions

What does tail -f do?

It follows a file and prints new data as it is appended.

What is tail -F?

It follows the pathname and can reopen the file after rotation or replacement.

How do I follow only errors?

Pipe tail into grep with `--line-buffered` so matches are displayed promptly.

The commands behind it

More how-to guides