Operating System - HP-UX
1837981 Members
1866 Online
110124 Solutions
New Discussion

Ouput buffering when not a terminal

 
Brenton Ough
New Member

Ouput buffering when not a terminal

I am using GNUs tail (multiple file capability) to have one consolidated log file. This is run from cron:
tail -q -f file* | egrep "warning|error" > error.log
Becuse of the way the stdio libraries work if the output device is a terminal you get no buffering, if not you get full buffering (for my system this is 8192 chars). This leads to delays in me recieving errors.
Does anyone know how I can either fool the cron job into thinking it is a terminal (preferably using hp-ux not something like expect) or any other way I can solve this.
Thanks,
Brenton
1 REPLY 1
Volker Borowski
Honored Contributor

Re: Ouput buffering when not a terminal

Hi,
did you try to write to a pipe first, and then read from the pipe with a dd and a smaller block-size ?

mknod pipe p
ls -l > pipe ; dd if=pipe of=error.log bs=1

Another idea is, if your gnu-tail is multiple capable, to fool him with a dummy error from a seperate stream, to force linefeeds, and eliminate the dummys later.

No idea if this works
Volker