【问题标题】:Redirect script output and at the same time display it in realtime重定向脚本输出,同时实时显示
【发布时间】:2012-10-17 13:23:29
【问题描述】:

关于显示多个脚本的输出并同时将它们的 stout/stderr 写入日志文件,我有一个可能很简单(甚至可能已经回答)的问题:

我有一个脚本“my_script.sh”,它本身会调用另一个类似的脚本:

./my_to_be_logged_script.sh 2>&1 | tee -a "$LOGFILE"

my_to_be_logged_script.sh 在其他操作中调用一个 Python 脚本和另一个类似的 shell 脚本:

./my_to_be_logged_shell_subscript.sh
python "my_to_be_logged_py_subscript.py" 

首先,所有内容都正确记录到 LOGFILE。

shell 脚本输出是实时显示的,但控制台仅在 Python 脚本完成后才会显示 Python 脚本的输出。有没有办法实时显示 Python 输出?

【问题讨论】:

标签: shell unix stdout tee


【解决方案1】:

试试 python -u "my_to_be_logged_py_subscript.py"

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-06-27
    • 2017-06-15
    • 2017-04-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-12-09
    相关资源
    最近更新 更多