Skip to main content
deleted 11 characters in body
Source Link
Nakilon
  • 35.2k
  • 16
  • 112
  • 149

I've got a script like:

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

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.

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

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

Thanks.

I've got a script like:

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

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.

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

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

Thanks.

I've got a script like:

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

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.

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

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

Source Link
bstpierre
  • 31.5k
  • 16
  • 74
  • 105

bash: force exec'd process to have unbuffered stdout

I've got a script like:

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

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.

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

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

Thanks.