I want to watch a log file

Viewed 26

I am running stuff on a server, and I find watch -n 30 qstat job.pbs a bit uninformative. Why can't I get

$ watch -n 30 less location/of/log|tail

to work? I get a blinking cursor. I do get output from

less location/of/log|tail
2 Answers

Try tail -f log.txt The -f option is designed to do exactly that: Every time the file is updated, it displays the addition.

I find less is more convenient if you want more than just following a log file (e.g., scrolling and searching etc.). E.g. open log file with less as follows:

less /path/to/log

then press

Shift+F - to follow the log (behaves just like tail -f)

Ctrl+C - to stop following the log

?pattern - to search backward in log file

Related