How to tell when a file is opened

Adam adamgarstang at googlemail.com
Sat Apr 7 14:22:41 EDT 2007


On Apr 7, 5:09 pm, Tim Golden <m... at timgolden.me.uk> wrote:
> 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

Sorry about not mentioning my platform.

What you mention looks promising. Will look into it. Like I said
knowing the last access time is not useful as I would have to be
constantly looping through the directory looking for changes.

Will look into NTFS change journals when I get some spare time.

Thanks for the reply.
Adam




More information about the Python-list mailing list