How to tell when a file is opened

Tim Golden mail at timgolden.me.uk
Sat Apr 7 12:09:29 EDT 2007


Adam wrote:
> I want to know if it possible to tell when a file is opened. However I
> don't want it to be the last access time. I want to know how many
> times a file opened so I can generate statistics of file usage.
> 
> I will be wanting to watch all files on a server so this will be on
> quite a large scale. So checking a directory on a loop for accesses
> won't work.
> 
> Maybe some way to monitor the Open Files section of Computer
> Management?
> 
> I check through Tim Golden's site but nothing jumped out at me.
> Any pointers would be great.

I take it from the fact that you mention my site (and
your reference to "Computer Management") that you're
looking at Win32? It's always best to be explicit when
you're asking for help; a lot of people on this list
will be using Linux or Mac where the answers are
probably very different.

This is no small task you've set yourself! As far as I know,
you're going to have to go down to the level of change journals
for this kind of thing. (Search for "NTFS change journal").

Although you might think: the filesystem knows when files are
being accessed; can't I hook into that directly? I think the
answer is: no. But I could be wrong.

TJG



More information about the Python-list mailing list