Skip to content
Latchkey

tail: Usage, Options & Common CI Errors

tail shows the end of a file - and with -f, streams new lines as they arrive.

tail is great for surfacing the last few lines of a log. The CI hazard is tail -f, which never returns on its own and will hang a job until it times out.

What it does

tail outputs the last part of input - the final 10 lines by default, a chosen count (-n), or from a starting line (-n +N). With -f it follows the file, printing appended data as it grows.

Common usage

Terminal
tail file.log                  # last 10 lines
tail -n 50 file.log
tail -n +2 data.csv           # skip the header, print from line 2
tail -f app.log               # follow (does NOT exit on its own)
tail -F app.log               # follow even across rotation

Options

FlagWhat it does
-n <N>Last N lines
-n +<N>Start at line N (skip a header)
-f / -FFollow the file (-F survives rotation)
-c <N>Last N bytes

Common errors in CI

tail -f blocks forever - in a pipeline it stalls the job until the CI timeout kills it. Use a bounded approach instead: run the process in the background, or wrap with timeout 60 tail -f, or tail the file once after the process exits. "tail: cannot open "X" for reading: No such file or directory" exits 1. -n +N (start at line N) is easy to confuse with -n N (last N lines).

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →