![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| tail, grep and cut | sylaan | Shell Programming and Scripting | 7 | 03-03-2008 11:41 PM |
| Badly placed ()'s. - error | amitrajvarma | Shell Programming and Scripting | 3 | 10-12-2007 01:40 AM |
| Help with tail /grep needed | Felix2511 | UNIX for Dummies Questions & Answers | 4 | 05-17-2007 12:22 PM |
| Constantly updating log files (tail -f? grep? awk?) | nortonloaf | UNIX for Dummies Questions & Answers | 0 | 12-03-2006 08:20 PM |
| New to it all, But i wanna script really badly!!! | TheNewGuy | Shell Programming and Scripting | 3 | 07-03-2004 07:33 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
tail | grep lagging badly
I'm trying to use tail/grep to monitor a log file. The command I cooked up is:
tail -n 50 -f output.log | grep 'type:system' | cut -f 5- A sample line from the log file is: 1208894862 type:system session:0 severity:4 load started the columns are tab delimited. this works ok, except that it's inexplicably lagging badly. If I have 2 terminals open, one simply tailing the file and the other tail|greping the file as specified above, it might take 30 seconds or more for the tail|grep terminal to display the next line while the tail terminal displays it instantly. EDIT: forgot to add this. Also, sometimes new text does not appear until even more txt is added to the log file. Example: 'test 1' is written to the log tail will show this right away, tail | grep will NOT 'test 2' is written to the log tail will show this right away, tail | grep will show both 'test1' and 'test2' now Any hints for me? Thanks in advance Last edited by WasabiVengeance; 04-22-2008 at 01:23 PM. |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
The pipe buffers I/O so it won't be printed until the output buffer is full. This is a classic FAQ. Google for "grep unbuffered" for example.
|
|
#3
|
|||
|
|||
|
Thank you for your reply, it's much appreciated.
I think I understand the issue, but I don't see an obvious solution in your reply. Should I not be using a pipe? Is there some grep option I should be using, or maybe awk or sed instead? |
|
#4
|
|||
|
|||
|
Some grep implementations have a --line-buffered option which would help. I don't think there is a standard, one-size-fits-all solution to this. Maybe a Perl script to do the tail and grep in the same process; that should certainly avoid any pipe buffering.
|
|||
| Google The UNIX and Linux Forums |