Tee and file redirections are very slow to write anything.
Wed Feb 24 23:26:54 GMT 2021
On Thu, 25 Feb 2021 09:41:49 +1100
Duncan Roe wrote:
> On Wed, Feb 24, 2021 at 04:58:24PM -0500, Eliot Moss wrote:
> > On 2/24/2021 3:48 PM, ASSI wrote:
> > > Hamish McIntyre-Bhatty via Cygwin writes:
> > > > I found recently when trying to save output from a script for later
> > > > inspection that "tee" and file redirections seem to have massive
> > > > delays when run in Cygwin - usually nothing is written to file or
> > > > stdout until after the command has finished - not very helpful.
> > >
> > > You will want to switch from fully buffered to line-buffered or even
> > > unbuffered output.
> > And this does not have to do with Cygwin. The same happens on Linux.
> > The default is that terminal I/O is unbuffered while other stream are
> > buffered. Pipes come under "other streams". One can make programmatic
> > changes to get around this, but most programs won't override the
> > default behavior on their own ...
> > Best -- Eliot Moss
> The (Linux) default is that terminal I/O is *line* buffered
> The man page for tee doesn't show an option to change buffering, while that for
> grep does.
However, in this case, output is not a 'terminal I/O' because it is
redirected to a file or a pipe.
Do these help?
"stdbuf -o L bash ./path/to/script.sh > stdout.log"
"stdbuf -o L bash ./path/to/script.sh | tee stdout.log"
Takashi Yano <firstname.lastname@example.org>
More information about the Cygwin