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?
相关问题
- Is shmid returned by shmget() unique across proces
- how to get running process information in java?
- I want to trace logs using a Macro multi parameter
- Error message 'No handlers could be found for
- convert logback.xml to log4j.properties
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 withless
, it will start following the end of the file just liketail -f
. Alternatively, you can startless
withless +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 useless
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 withtail -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, whiletail -F
will watch for a new file being created, and start following that instead. If you're usingless
to follow the file, you can use the--follow-name
flag to makeless
act this way as well.(thanks to ephemient for the tips on
less +F
andless --follow-name
)-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.