我想要一种tail -f
读取整个文件然后在写入时继续遵循它的行为。
解决方案
根据我接受的答案,这是有效的: tail -f -n +1 {filename}
工作原理:该-f
选项继续“跟随”文件并在将新行写入文件时输出新行。该-n +1
指示tail
开始阅读从第一行的文件。使用-n -10
将从文件的最后十行开始。
我刚刚安装了 Ubuntu 16.04,当我启动SmartGit时收到此警告:
IOException: User limit of inotify watches reached
Run Code Online (Sandbox Code Playgroud)
此外,我收到此警告启动tail -f
:
tail: inotify resources exhausted
tail: inotify cannot be used, reverting to polling
Run Code Online (Sandbox Code Playgroud)
我在 Ubuntu 14.04 上从来没有遇到过这个错误,我在新 Ubuntu 上使用的应用程序和文件与我在以前的版本中使用的完全一样。
唯一相关的区别是我在 PC 上添加了一个额外的硬盘,并配置了 Ubuntu 的备份工具。这个问题是否与第二个磁盘或备份工具有关?
您能推荐一个具有强大日志监视功能的 GUI 应用程序吗?
通常它会像tail -f
在 GUI 中一样工作,但除此之外,以下功能将非常有用:
Windows 上的一个类似工具是BareTail及其付费版本 - BareTailPro
假设我们这样做:
tail -f /var/log/apache2/error.log
Run Code Online (Sandbox Code Playgroud)
然后我们看到我们想看到的,然后,我们想退出,这样我们就可以导航到其他目录等等……所以,问题是:
我们怎样才能退出tail?
我试着输入:'q'、'exit'、'quit'和'kill',没有运气。
When I try to tail -f catalina.out
, I get the error:
tail: inotify cannot be used, reverting to polling: Too many open files
Run Code Online (Sandbox Code Playgroud)
I tried the answer in this post: Too many open files - how to find the culprit
lsof | awk '{ print $2; }' | sort -rn | uniq -c | sort -rn | head
Run Code Online (Sandbox Code Playgroud)
When I ran the above command, the output was
17 6115
13 6413
10 6417
10 6415
9 6418
9 6416 …
Run Code Online (Sandbox Code Playgroud) 有时我可能需要访问多个日志文件进行故障排除,但我不想在不同的终端中打开它们。
我想要的是在同一个终端中打开它们。
有什么办法可以在同一个终端窗口中查看多个日志文件的尾部?
我有一个 Web 应用程序,它输出到许多带有性能信息的日志文件。一个日志文件输出代码执行时间,另一个输出 SQL 计时。我无法控制记录器或生成日志文件的代码,但我想在一个地方输出日志。
目前我正在做这样的事情
tail -f sqlLogs.log | grep sql-time
tail -f perflogs.log | grep exec-time
Run Code Online (Sandbox Code Playgroud)
每次在应用程序中执行 SQL 时,都会向控制台输出一些内容。但是我必须在两个单独的 SSH 会话中运行代码。但是,我希望能够在同一个 SSH 会话中尾随两个文件。这可能吗?
在这个答案中(如何使用 sed 删除文件的第一行?)有两种方法可以删除文件中的第一条记录:
sed '1d' $file >> headerless.txt
Run Code Online (Sandbox Code Playgroud)
** - - - - - - - - 或者 - - - - - - - - **
tail -n +2 $file >> headerless.txt
Run Code Online (Sandbox Code Playgroud)
我个人认为该tail
选项在外观上更令人愉悦且更具可读性,但可能是因为我受到了sed-challenged。
哪种方法最快?
我是 Ubuntu 的新手。我之前运行了 atail -f /var/logs/syslog
并获得以下显示结果:
kernel: [ 2609.699995] [drm:gen6_sanitize_pm] *ERROR* Power management discrepancy: GEN6_RP_INTERRUPT_LIMITS expected 000d0000, was 1a0d0000
Run Code Online (Sandbox Code Playgroud)
这意味着什么?
我有以下内容。
我需要在启动 Java 进程后读取日志文件以检查正确启动。
我尝试过,tail -f
但它永远保持追加。tail
打印 n 行后我需要停止。-n
previuos 行有类似选项的方式吗?