How to streamingly read text file and display whenever updated text

Chris Angelico rosuav at gmail.com
Sat Oct 5 23:28:02 EDT 2013


On Sun, Oct 6, 2013 at 2:17 PM,  <galeomaga at gmail.com> wrote:
> After tried many times, updated text file is not shown, it only print text at the first time.

The implementation of tail has a lot of little oddities to deal with
edge cases. Why not simply use it?

A while ago, I wanted to make a system that would tail a bunch of logs
on a bunch of computers, and display it all to me in a single unified
view. Rather than write something that opened a whole lot of files and
monitored them, I simply forked a 'tail' process for each file and
reacted to its stdout. It was way WAY easier than dealing with
everything that could possibly happen (log rotation, etc, etc, etc) -
not that it'd be impossible to deal with, but it's a waste of time
reinventing this particular wheel. Build on top of what's already
there, save yourself the trouble.

ChrisA



More information about the Python-list mailing list