开发者

View a log file in Linux dynamically [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.

This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange 开发者_如何学Gosite, you can leave a comment to explain where the question may be able to be answered.

Closed 6 years ago.

Improve this question

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?


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)


tail -f foo.csv


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).


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.


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.


tail -lf logfile.csv.

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


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)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜