输出到文件的强制冲洗,而bash脚本仍在运行 [英] Force flushing of output to a file while bash script is still running

查看:133
本文介绍了输出到文件的强制冲洗,而bash脚本仍在运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个小的脚本,这是由crontab中使用以下命令每天名为:

I have a small script, which is called daily by crontab using the following command:

/homedir/MyScript &> some_log.log

使用此方法的问题是,some_log.log的MyScript结束后仅创建。我想程序的输出刷新到该文件中,而它的运行,所以我可以做这样的事情。

The problem with this method is that some_log.log is only created after MyScript finishes. I would like to flush the output of the program into the file while it's running so I could do things like

tail -f some_log.log

和跟踪的进展等。

推荐答案

庆典本身实际上从未写任何输出到您的日志文件。相反,命令它调用的脚本的一部分将各自单独输出写入和冲洗时,他们喜欢它的感觉。所以,你的问题实在是如何强制bash脚本中的命令来冲洗,而这取决于它们是什么。

bash itself will never actually write any output to your log file. Instead, the commands it invokes as part of the script will each individually write output and flush whenever they feel like it. So your question is really how to force the commands within the bash script to flush, and that depends on what they are.

这篇关于输出到文件的强制冲洗,而bash脚本仍在运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆