[ALUG] Standard output redirection caching
(Ted Harding)
ted.harding at nessie.mcc.ac.uk
Fri Jun 1 12:44:30 BST 2007
On 01-Jun-07 10:04:52, Dan Hatton wrote:
>
> Dear All,
>
> When standard output is redirected to a file, it gets cached, so that
> nothing is actually written to the file until (say) 4kB of standard
> output has built up. I'm sometimes too impatient to wait that long to
> see the output of my programs, especially when the program in
> question is a long, slow numerical calculation that might be producing
> only a few hundred bytes of output per day. Is there any way of
> either switching off this caching, or inspecting the contents of the
> cache before it gets written, please?
>
> --
>
> Thanks very much
>
> Dan Hatton
I just realised that I inadvertently, in my previous response,
answered your "Is there any way of ... inspecting the contents
of the cache before it gets written?" in the affirmative!
Namely, as I put in as an afterthought, use "tail -f". Example:
Have 2 xterms going. In xterm 1:
echo `date` > myoutfile
(note backquotes). In xterm 2:
tail -f myoutfile
and see one line like "Fri Jun 1 12:38:45 BST 2007". Now, in xterm 1:
while true ; do echo `date` >> myoutfile ; sleep 2 ; done
and watch the output accumulate in xterm 2, every 2 seconds
(i.e. you're seeing it before the cache gets flushed). So far:
Fri Jun 1 12:38:45 BST 2007
Fri Jun 1 12:40:31 BST 2007
Fri Jun 1 12:40:33 BST 2007
Fri Jun 1 12:40:35 BST 2007
Fri Jun 1 12:40:37 BST 2007
Fri Jun 1 12:40:39 BST 2007
Fri Jun 1 12:40:41 BST 2007
Fri Jun 1 12:40:43 BST 2007
Fri Jun 1 12:40:45 BST 2007
Fri Jun 1 12:40:47 BST 2007
Fri Jun 1 12:40:49 BST 2007
Fri Jun 1 12:40:51 BST 2007
Fri Jun 1 12:40:53 BST 2007
Fri Jun 1 12:40:55 BST 2007
Fri Jun 1 12:40:57 BST 2007
Fri Jun 1 12:41:00 BST 2007
Fri Jun 1 12:41:02 BST 2007
Fri Jun 1 12:41:04 BST 2007
Fri Jun 1 12:41:06 BST 2007
Fri Jun 1 12:41:08 BST 2007
Fri Jun 1 12:41:10 BST 2007
Fri Jun 1 12:41:12 BST 2007
Kill either program with ^C when desired.
Ted.
--------------------------------------------------------------------
E-Mail: (Ted Harding) <Ted.Harding at manchester.ac.uk>
Fax-to-email: +44 (0)870 094 0861
Date: 01-Jun-07 Time: 12:42:08
------------------------------ XFMail ------------------------------
More information about the main
mailing list