[PLUG] more buffering than i'd like
Tim
tim-pdxlug at sentinelchicken.org
Fri Apr 11 14:19:58 UTC 2008
Hello Russell,
On Fri, Apr 11, 2008 at 04:04:56AM -0700, Russell Senior wrote:
>
> I have a program, called sample, that logs data to a file using stdout
> redirection:
>
> $ sample > output.data
>
> When I check on the output.data file, e.g. with tail -f:
>
> $ tail -f output.data
>
> not unexpectedly, I get blocky output as the redirect is being
> buffered somewhere or other. This is all familiar, but ... I'd like
> to make it not be buffered (that is, I want the lines to show up as
> the come out of "sample") and I vaguely remember making something like
> that happen in the Before Time. Unfortunately, that's about all I
> remember. Anyone kind enough to supply me a refresher?
If your program is written in C, you could try using fflush(3) or
fsync(2) to clear the buffer after each line or other logical data chunk
is written.
If your program is a Python script, then try sys.stdout.flush().
HTH,
tim
More information about the PLUG
mailing list