[英]redirect nohup stdout and flush
I want to use nohup and redirect stdout to a file but I do not need a archive I just want to be able to interactively view the current stdout. 我想使用nohup并将stdout重定向到文件,但是我不需要存档,我只想能够以交互方式查看当前stdout。 I am thinking I can redirect the stdout to a file to for it to be flushed after each output
我想我可以将stdout重定向到一个文件,以便在每次输出后将其刷新
??? ??? nohup ruby myapp.rb > output.log &
nohup ruby myapp.rb> output.log和
interactly view the output tail -F ./output.log 交互查看输出tail -F ./output.log
You'll need to take a look at my answer to another question here: Linux non-blocking fifo (on demand logging) . 您需要在这里查看我对另一个问题的回答: Linux非阻塞fifo(按需记录) 。
Assuming that by now you've got the ftee
program ready, if you call your app like this: 假设现在您已经准备好
ftee
程序,如果您这样调用应用程序:
$ mkfifo /tmp/mylog
$ nohup ruby myapp.rb 2>&1 | tee output.log | ftee /tmp/mylog &
you'll get: 你会得到:
output.log
output.log
/tmp/mylog
fifo /tmp/mylog
fifo可按需提供应用程序的当前输出 Now if you want to just take a peek at your prog's latest output do: 现在,如果您只想看一下编的最新输出,请执行以下操作:
$ cat /tmp/mylog
Hope this helps. 希望这可以帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.