Boston Linux & Unix (BLU) Home | Calendar | Mail Lists | List Archives | Desktop SIG | Hardware Hacking SIG
Wiki | Flickr | PicasaWeb | Video | Maps & Directions | Installfests | Keysignings
Linux Cafe | Meeting Notes | Blog | Linux Links | Bling | About BLU

BLU Discuss list archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Discuss] bash output buffering



John Abreau <abreauj at gmail.com> writes:

> On Wed, Jun 13, 2012 at 7:06 AM, Edward Ned Harvey <blu at nedharvey.com> wrote:
>
>> A command inside of bash generates output every second (ping) redirected to
>> a file.
>> If you run the command on an interactive shell, then you can tail -f the
>> file, and see the output "live" as it happens.
>> But if you run the command inside an "at" script, or a cron script, you tail
>> -f the file... And nothing appears for a few minutes, and then it all
>> appears suddenly.
>>
>> This is bash buffering the output of ping, before redirecting to file. All
>> of which is a level above the OS filesystem buffering.
>
> What you're describing is the difference between OS tty buffering vs
> OS filesystem buffering. This has nothing at all to do with bash; both
> occur below bash at the OS level.
>
> The difference is that OS filesystem buffering is block-oriented, and
> OS tty buffering is character-oriented.

    Just to add something to google for, Ed is probably dealing with
stdio buffering.  setvbuf(3).  Technically libc, rather than the OS.  I
don't know if bash exposes anyway to fiddle with it, a brief google
mentioned an LD_PRELOAD hack.



BLU is a member of BostonUserGroups
BLU is a member of BostonUserGroups
We also thank MIT for the use of their facilities.

Valid HTML 4.01! Valid CSS!



Boston Linux & Unix / webmaster@blu.org