Viewing a log file in Linux dynamically

I have a .csv log file on Linux that is constantly being updated. I want to view the log file as it is updated. Are there any Linux commands for this?

+52
linux logging
Jan 20 '10 at 5:02
source share
8 answers

tail -f yourlog.csv

Added lines will be constantly displayed.

+89
Jan 20
source share
โ€” -

As others have pointed out, tail -f file is the most common solution. The problem is that the results simply scroll, and you cannot go back and look for them if your terminal does not support it and you have enough buffered lines in your terminal.

A lesser known solution that I like is to use less ; if you type Shift - F when viewing a file with less , it will start following the end of the file, like tail -f . Alternatively, you can run less with less +F to enter this mode at startup. You can type Ctrl - C at any time to stop the file from executing, and then go up and down, search with / and use less , as usual. This can be very useful if you see something interesting in the magazine, but it scrolls from the screen or if you want to come back a bit to check something that you might have missed. When you are done searching, press Shift - F again to start the file again.

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

tail -f (i.e. capital -F , unlike lowercase -F ) is a non-standard flag (available for Linux, Cygwin, MacOS X, FreeBSD and NetBSD) that works best for viewing log files that can sometimes rotate; rename the log file for the process, and then create a new log file instead to avoid too much of a single log file. tail -f will continue to follow the old file, which is no longer the active log file, and tail -f will follow the creation of the new file and instead start following it. If you use less to monitor the file, you can use the --follow-name flag to make less same.

(thanks to the ephemerality for hints on less +F and less --follow-name )

+58
Jan 20
source share

tail -f foo.csv

+11
Jan 20
source share

Just in case, if you want to control several files, there is a good tool called multitail , which allows you to combine the output of two or more files and track them in real time. multitail also allows you to move forward and backward in controlled files.

+8
Jan 20 '10 at 16:22
source share

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

+5
Jan 20 '10 at 16:29
source share

tail -lf logfile.csv.

If you are logged into the GUI, you can use the mouse pad to dynamically view the log.

0
Jan 20 '10 at
source share

vsConsole FileView can help if you prefer to track your logs through a web application. See Demo at http://demo.vamonossoftware.com/

You need to start the Java application server, deploy vsConsole and run the agents on the server containing the logs, so I assume this is a harder solution than what you need here. (Good for developers / testing teams who just want to click the log file to see it, not ssh, cd, tail, etc.)

0
03 Feb '11 at 3:23
source share
 less -S '-#' 4 /var/log/logfile 

-S will stop the annoying line wrapper.

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

Press the Finish key to update.

0
Oct 22 '16 at 19:42
source share



All Articles