庆典:强制exec'd过程中有缓冲的标准输出 [英] bash: force exec'd process to have unbuffered stdout

查看:159
本文介绍了庆典:强制exec'd过程中有缓冲的标准输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经有了喜欢的脚本:

I've got a script like:

#!/bin/bash
exec /usr/bin/some_binary > /tmp/my.log 2>&1

问题是, some_binary 将其所有日志记录到标准输出,和缓冲使得它如此,我只能看到几行块输出。当东西卡住,我需要看到最后一行说什么这是烦人。

Problem is that some_binary sends all of its logging to stdout, and buffering makes it so that I only see output in chunks of a few lines. This is annoying when something gets stuck and I need to see what the last line says.

有没有什么办法,使标准输出缓冲之前,我做了EXEC会影响some_binary所以它有更多有用的日志?

Is there any way to make stdout unbuffered before I do the exec that will affect some_binary so it has more useful logging?

(该包装脚本只设置Exec之前一些环境变量,所以在Perl和Python的解决方案也将是可行的。)

(The wrapper script is only setting a few environment variables before the exec, so a solution in perl or python would also be feasible.)

推荐答案

您可能会发现,自带的无缓冲脚本://预期.sourceforge.net /> 期望 可能会有帮助。

You might find that the unbuffer script that comes with expect may help.

这篇关于庆典:强制exec'd过程中有缓冲的标准输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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