Re: *nice* maillog output

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

 



On Tue, Jun 22, 2004 at 04:36:32PM -0500, Jeff Vian wrote:
> 
> 
> Craig Tinson wrote:
> 
> >ok.. re previous post about "fix"
> >
> >it doesn't work.. lol
> >
> >why would:
> >
> >tail -500 /var/log/maillog | grep -v imapd |grep -v connection |grep 
> >-v processing| cut -d" " -f0,3,6,7,8,9,10| grcat conf.craig
> >
> >work.. but
> 
> This one ends the tail output and passes it to grep .... etc
> 
> >
> >tail -f /var/log/maillog | grep -v imapd |grep -v connection |grep -v 
> >processing| cut -d" " -f0,3,6,7,8,9,10| grcat conf.craig
> >
> >*not* work..
> 
> This one never ends the tail output, so it never releases control to the 
> following commands. Grep is waiting for the end of the input before it 
> gives the output.

Not the end of input. There's never a question of releasing control. The
problem is the buffered stdio routines. Well, not really a problem, it's
just unwanted behaviour in this case.

tail -f will use fwrite/fprintf/printf that will use block buffer on
standard output, versus the normal line buffered output for tty devices.

grep, on the other end, will also use buffered input and output.

With sufficient input for tail, resulting in sufficient output to fill
buffers, the lines will come out.

This can be tested by also specifying -f in the first case (tail -n 500 -f
...). If it works, then it's a buffer problem.

Most cli programs support options to change from buffered output to line
buffering. In the case of grep, it's --line-buffering.

So the line can be changed to:
tail -F /var/log/maillog | egrep --line-buffering -v \
	'imapd|connection|processing' | cut -d" " -f0,3,6,7,8,9,10 \
	| grcat conf.craig

(tail -F to reopen the log file when it's rotated.)

Regards,
Luciano Rocha

-- 
Consciousness: that annoying time between naps.



[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux