Kev*_*777 24 monitoring tail files
如何打开文本文件并让它自行更新?top工作方式类似。
我想打开一个日志文件并观察它动态更新。
我刚刚试过:
$ tail error.log
Run Code Online (Sandbox Code Playgroud)
但刚刚意识到,它只是向您显示日志文件中的行。
我正在使用 RHEL 5.10
ter*_*don 34
您正在寻找tail -f error.log(来自man tail):
-f, --follow[={name|descriptor}]
output appended data as the file grows; -f, --follow, and --fol?
low=descriptor are equivalent
Run Code Online (Sandbox Code Playgroud)
这将让您观看文件并查看对其所做的任何更改。
Vol*_*gel 24
您可以使用tail -f error.log或更好:tail -F error.log.
但是如果你想在文件中回滚,那不是很有用。
和
less +F error.log
Run Code Online (Sandbox Code Playgroud)
您获得了 的功能tail -f,
但可以 使用+中断对新输入的读取。CtrlC
然后,您处于正常less模式,
您可以回滚以查看您可能错过的Up/Down
此外,您可以使用Left/读取长日志文件行而无需换行Right
您还可以使用/、?向后n和N下一个/上一个搜索正则表达式。
日志文件非常有趣的是,您可以使用隐藏所有不匹配的行进行搜索&,仅过滤掉匹配项。
随着F内less,你不断的tail -f样模式。
该+命令行less +F是指“按这些键开始少后直接”。
所以我们F在启动时使用了keypress ,描述为:
F Scroll forward, and keep trying to read when the end of file is
reached. Normally this command would be used when already at the
end of the file. It is a way to monitor the tail of a file which
is growing while it is being viewed. (The behavior is similar to
the "tail -f" command.)
Run Code Online (Sandbox Code Playgroud)
另请参阅multitail是否需要查看多个日志文件。
使用-f选项tail:
-f, --follow[={name|descriptor}] 随着文件的增长输出附加数据;-f、--follow 和--follow=descriptor 是等价的
或者F在里面使用命令less:
F Scroll forward, and keep trying to read when the end of file is reached. Normally this command would be used when already at the end of the file. It is a way to mon?
itor the tail of a file which is growing while it is being viewed. (The behavior is similar to the "tail -f" command.)
Run Code Online (Sandbox Code Playgroud)