持续输出文件内容到控制台?
快速问题,希望......我正在构建一个具有相当广泛的日志文件的应用程序。我希望能够随时监控应用程序的特定实例正在执行的操作。我可以多次打开和关闭日志文件,但这有点痛苦。最佳情况下,当行写入日志文件时,它们也会写入控制台。所以我希望存在类似“cat”的东西,它实际上会阻塞并等待输入文件中提供更多内容。有人有什么想法吗?
Quick question, hopefully... I'm building an application with a fairly extensive log file. I'd like the ability at any time to monitor what a specific instance of my application is doing. I could open and close the log file a bunch of times, but its kind of a pain. Optimally, as lines are written to the log file, they would be written to the console as well. So I'm hoping something along the lines of "cat" exists that will actually block and wait for more content to be available in the input file. Anyone have any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
这将使其保持打开状态并“遵循”新的输出。
this will keep it open and 'follow' the new output.
tail -f 日志文件
tail -f logfile
多样化的替代答案:如果您已经在使用 less 查看日志文件,请按大写 F 让它执行与 tail -f 相同的操作:等待附加新内容并显示它。
An alternate answer for variety: If you're already looking at the log file with less, press capital F to get it to do the same thing tail -f does: wait for new content to be appended and show it.
查看 tee 实用程序
Look at tee utility
http://www.devdaily.com/blog/post/linux-unix/use-unix-linux-tee-command-send-output-two-or-more-directions-a