Recognizing the Arrival of a New File
Christos TZOTZIOY Georgiou
tzot at sil-tec.gr
Tue Mar 8 16:10:42 CET 2005
On Tue, 08 Mar 2005 08:43:04 -0600, rumours say that Greg Lindstrom
<greg.lindstrom at novasyshealth.com> might have written:
>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.
The most common way to watch for a file or a directory change (in my experience)
is to use the SGI fam (file alteration monitor); I think it has been ported to
Linux. Otherwise, either way you describe is common use. Suggestion: first
check for changes in the st_mtime of the directory, then search for the file
TZOTZIOY, I speak England very best.
"Be strict when sending and tolerant when receiving." (from RFC1958)
I really should keep that in mind when talking with people, actually...
More information about the Python-list