View a log file in Linux dynamically

LinuxLogging

Linux Problem Overview


I have a log file in .csv format in Linux, that is being updated continuously. I want to view the log file as it is being updated. Is there any Linux command(s) to do that?

Linux Solutions


Solution 1 - Linux

tail -f yourlog.csv

Newly appended lines will continuously show.

Solution 2 - Linux

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)

Solution 3 - Linux

tail -f foo.csv

Solution 4 - Linux

Just in case you want to monitor multiple files, there is a nice tool called multitail that lets you merge the output from two or more files and track them in real time. multitail also lets you navigate back and forth in the monitored file(s).

Solution 5 - Linux

tail -f and all its friends are old school. multitail looks better but the real way to burn CPU watching your log files is to use glTail.

Solution 6 - Linux

less -S '-#' 4 /var/log/logfile

-S will stop the annoying line-wrapping.

-# 4 will set the horizontal scrolling step to four columns, instead of the default of half the screen.

Press the End key to refresh.

Solution 7 - Linux

tail -lf logfile.csv.

If you logged on to GUI, you can use mousepad to view the log dynamically.

Solution 8 - Linux

vsConsole FileView may help if you prefer to monitor your logs via a web application. See the demo at http://demo.vamonossoftware.com/

Requires you run a java app server, deploy vsConsole to it, and run agents on the server containing the logs - so I'm guessing its a more heavy weight solution than what you need here. (Its good for dev/testing teams who just want to click on a log file to see it rather than ssh, cd, tail etc)

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionAshwinView Question on Stackoverflow
Solution 1 - LinuxteerapapView Answer on Stackoverflow
Solution 2 - LinuxBrian CampbellView Answer on Stackoverflow
Solution 3 - LinuxPeteView Answer on Stackoverflow
Solution 4 - Linuxgareth_bowlesView Answer on Stackoverflow
Solution 5 - LinuxNoufal IbrahimView Answer on Stackoverflow
Solution 6 - LinuxOskar SkogView Answer on Stackoverflow
Solution 7 - LinuxBooleanView Answer on Stackoverflow
Solution 8 - LinuxPaulView Answer on Stackoverflow