Recognizing the Arrival of a New File

Chris Green cmg at dok.org
Wed Mar 9 17:46:12 EST 2005


Greg Lindstrom <greg.lindstrom at novasyshealth.com> writes:

> Hello-
> I am writing an application where I need to recognize when a file 
> arrives in a given directory.  Files may arrive at any time during the 
> course of the day.  Do I set up a cron job to poll the directory every 
> few minutes?  Write a daemon to monitor the directory?  Or is there some 
> other more common/accepted way to perform this task?  I'm using Python 
> 2.3 on Linux.

At my last job, we had a similar problem and I wanted to be able to
check that the file was closed by the application that was putting it
there (in that case the application was w32 writing to a share via
samba).

http://cmg.dok.org/cgi-bin/pyblosxom.cgi/python/linuxlease/

Every other way I could find that relied on simple FS semantics had
the possibility of reading a file partially.
-- 
Chris Green <cmg at dok.org>
Eschew obfuscation.



More information about the Python-list mailing list