« A Year Ago Today I Almost Died | Main | Faking PhantomJS's userAgent in Nightwatch.js »

grep and buffering

Recently while trying to troubleshoot a production issue I needed to tail a log and grep for some data. Problem was the data I was expecting to show up didn't. Well not exactly. It showed up about 10 minutes after I expected it to. Turns out using grep twice on a tail buffers like crazy.

tail -f /var/log/nginx/access.log | grep | grep -i html

You can fix the delay in showing results by using the line buffered flag to the middle grep like so:

tail -f /var/log/nginx/access.log | grep --line-buffered | grep -i html

Tags: grep

Post a comment

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)