View a log file in Linux dynamically [closed] View a log file in Linux dynamically [closed] linux linux

View a log file in Linux dynamically [closed]


tail -f yourlog.csv

Newly appended lines will continuously show.


As others have pointed out, tail -f file is the most common solution. The problem is that the results just scroll by, and you can't go back and search them unless your terminal supports it and you have enough lines buffered in your terminal.

A less known solution that I like is to use less; if you type Shift-F while viewing a file with less, it will start following the end of the file just like tail -f. Alternatively, you can start less with less +F to enter this mode on startup. At any time, you can type Ctrl-C to stop following the file, and then page up and down, search using /, and use less just like normal. This can be really helpful if you see something interesting in the log, but it scrolls off screen, or if you want to go back a bit to check on something you might have missed. Once you're done searching around, hit Shift-F again to start following the file again.

multitail looks like a nice solution for following multiple files in separate windows; if you view multiple files with tail -f, they will each be interleaved with each other (with headers to distinguish them), which may not be the way you want to watch them.

tail -F (that is capital -F, as opposed to lowercase -f) is a non-standard flag (available on Linux, Cygwin, MacOS X, FreeBSD and NetBSD), that works better for watching log files, which may be rotated occasionally; it's common for a process to rename a log file, and then create a new log file in its place, in order to avoid any one log file getting too big. tail -f will keep following the old file, which is no longer the active log file, while tail -F will watch for a new file being created, and start following that instead. If you're using less to follow the file, you can use the --follow-name flag to make less act this way as well.

(thanks to ephemient for the tips on less +F and less --follow-name)