Any idea to emulate tail -f

norseman norseman at
Wed May 6 01:28:41 CEST 2009

Joel Juvenal Rivera Rivera wrote:
> I want to make something very similar to  the command tail -f (follow a
> file), i have been trying  with some while True and some microsleeps
> (about .1 s); did someone has already done something like this?
> And about the file is the apache acceslog  of a site with a lot of
> traffic.
> Regards    
> joe / Joel Rivera
> --
I read the 4 replies available at this point in time. I agree with them 
in the general sense.

Question 1:  Why not use tail -f | ??
               (The obvious answer is that you are not in a Unix OS)

Question 2:  Have you looked at Popen2.popen3? (No, you are not in ..)
                In the Unix environment one can output to log files that
                are actually named pipes. Program 'up and running' leaves
                the keyboard (or in this case stdin) open.  Kinda like
                typing something into the letter, go to lunch, come back
                and type in some more.  Self regulating.  Might be able
                to dummy up something that emulates the concept.

Question 3:  How much CPU time do you need dedicated to this?
                Running a program again every 0.1seconds uses resources.
                CRON at x-minute intervals uses less. (bigger the x, less
                the resources.)

Question 4:  Is the program looking for things that, if found, need to
                sound the Claxton (nasty ear ponding alarm noise)?
              Or is it just to update the monitor over there on the side?
                (ie.. How time critical is it?) This effects Q3's answer.

Question 5:  Does the monitor machine just have to be NOT Linux?
              Does the log file just have to be NOT on a Linux machine?

If the Claxton is the point of your program, consider Q5 carefully.  If 
for some reason the log can not reside on a Linux/Unix drive, see if 
samba type linkage from a Linux to the logfile OS is doable. (It is if 
the IT types don't get in the way.)  From Linux you then mount the samba 
and use the soft link and run your program accordingly and it works as 
hinted in questions 1 and 2. Soft link is created by:
ln -s /path/real_file /different_path/same_or_different_f-name
2nd is treated as original and reacts same as if it were.

I would make one request.  Please tell people the OS you want the 
program on when you ask the question originally. To use yours:

"I want to make something very similar to the command tail -f ..." FOR 
USE IN MS WINDOWS XP.  or whatever.
XP and VISTA have frustrating differences and neither are UNIX or MAC.

I know I haven't given anything like the answers the others provided, 
but then I really am not sure of the intended use or OS.

Fire alarms are one thing, gleaning is another.  One is extremely time 
critical while for the other "tomorrow" is OK.


More information about the Python-list mailing list