Using ST_ATIME to watch for files being read

Chris iamlevis3 at hotmail.com
Fri Apr 2 10:39:38 EST 2004


I need to monitor a bunch of files to see what is being opened, read,
and closed, with no modifications being made.  This is being done
first on Windows machines, and later on Solaris.

Looking through Python Programming on Win32, I saw the ST_ATIME (page
311) which looked promising, but when I did a little test, the results
weren't good (read: sucked):

# from the i.shell.  st_atime date is inside >>><<<
>>> os.stat("c:\\devtemp\\python\\1.txt")
(33206, 0L, 2, 1, 0, 0, 3L, >>>1080919329<<<, 1080919329, 1080918583)

# now i open c:\devtemp\python\1.txt, close it, and rerun
>>> os.stat("c:\\devtemp\\python\\1.txt")
(33206, 0L, 2, 1, 0, 0, 3L, >>>1080919329<<<, 1080919329, 1080918583)

The Win32 books states that stat.ST_ATIME is "the time the file was
last accessed or zero if the filesystem doesn't support this
information".  Obviously I'm missing something, or maybe atime isn't
the best thing for me to use in this situation.  Hoping someone can
provide guidance.

TIA
-cjl



More information about the Python-list mailing list