473,387 Members | 1,693 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Using ST_ATIME to watch for files being read

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
Jul 18 '05 #1
1 2378
On 2 Apr 2004 07:39:38 -0800, rumours say that ia*******@hotmail.com
(Chris) might have written:

Hi Chris,
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.
<snip>
# 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


How exactly do you open the file? Through python or through an external
program (eg notepad)? If only through python, do you read any data? I
believe you have to read data for the access time to be updated.
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.


Windows has a weird behaviour even with st_mtime... I have a directory
structure in a USB disk, which, taking advantage of NTFS capability for
hard links, I present under two different views for the users of my
network. To avoid re-reading the contents of all files, I keep a cache
of (relative-filename, size, modification time); by comparing the cache
to the actual directory structure, every time I change a couple of
files, I read only the changed ones to decide where in the linked
structures I will present them.

I have found (through trial and error) that the modification time does
not show up immediately, esp. if the file is modified in the linked
directory structures... I tried even using a sync.exe from sysinternals,
but that doesn't change a lot. So, after a change, I wait a couple of
minutes and then I run the python script that relinks the files.
Everything works this way.
--
TZOTZIOY, I speak England very best,
Ils sont fous ces Redmontains! --Harddix
Jul 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: jason | last post by:
Does anyone have any ideas on a PAGE WATCH tool or an application that allows a user to be notified when page changes automatically by email. My immediate thoughts would be to use the FSO object...
1
by: Troy Murphy | last post by:
I seem to remember using a walkthru in the early beta that demonstrated how to create a Windows Service that would monitor events in a folder. Can someone please direct me to an example of doing...
5
by: Mark | last post by:
Hi all, I am trying to execute a batch file to copy over files from one server to another. The batch file is using robocopy to copy over the files. ============ private void CopyFiles() {// Use...
8
by: Sunil Menon | last post by:
Dear All, We are developing applications in ASP.Net...in one of our applications we would like to use a GridControl...we have tried to use a Server-Side Grid control but found the speed to be an...
1
by: batista | last post by:
Hello all, I have a grid that im updating using webservice.htc after every 5 sec. But i read after i used it that webservice.htc has severe memory leak.(my badluck :) ) So, now someone...
5
by: Michael Sperlle | last post by:
Is it possible? Bestcrypt can supposedly be set up on linux, but it seems to need changes to the kernel before it can be installed, and I have no intention of going through whatever hell that would...
8
by: ronen.chen | last post by:
I noticed that some sites use <script src='fineName.js?ver=XXX'></script(even google) Someone told me that it's for script changes, means - if the file in server has been changed than the new XXX...
3
by: JDeats | last post by:
I have some .NET 1.1 code that utilizes this technique for encrypting and decrypting a file. http://support.microsoft.com/kb/307010 In .NET 2.0 this approach is not fully supported (a .NET 2.0...
9
by: dgleeson3 | last post by:
Hello All I have a txt file of strings of different lengths. I dont know how many strings are in the file. I have no problem reading the file and sending to the console (as below). To...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.