如何使用timeout命令在文件中获取日志?(How to get logs in a file when using the the timeout command?)

编程入门 行业动态 更新时间:2024-10-03 10:40:40
如何使用timeout命令在文件中获取日志?(How to get logs in a file when using the the timeout command?)

我试图将我下面的命令的日志抓到如下的文本文件:

timeout 10 glxheads &> test.txt

但不幸的是,我没有通过这种方法将任何日志传输到文本文件。

事实上,在超时时间内完成的任何简单命令都不会将输出发送到文件。

注意:下面的命令有效,

glxheads &> test.txt

任何人都可以提出任何想法来解决这个问题?

谢谢 !

I am trying to grab the logs of my below command to a text file like below:

timeout 10 glxheads &> test.txt

But unfortunately, I am not not getting any logs transferred to the text file by this approach.

Infact any simple command done under timeout doesnt give out the output to a file.

Note: The below command works,

glxheads &> test.txt

Could anyone suggest any ideas to get around this issue?

Thanks !

最满意答案

根据Dmitri指定的链接,我可以通过执行以下操作来解决此问题:

stdbuf -oL -eL timeout 10 glxheads &> test.txt

或使用

unbuffer timeout 10 glxheads &> test.txt

As per the link specified by Dmitri, I was able to resolve this issue by doing the following:

stdbuf -oL -eL timeout 10 glxheads &> test.txt

or using

unbuffer timeout 10 glxheads &> test.txt

更多推荐

本文发布于:2023-07-09 10:16:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1085581.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何使用   命令   文件   日志   timeout

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!