I want to get when the file accessed last time, I tried following code:
import os, time
os.system("python test.py")
print os.stat('test.py').st_atime
time.sleep(60)
os.system("python test.py")
print os.stat('test.py').st_atime
But each time the output is same as follows :
1358489344.72
1358489344.72
I was expecting a difference in output before delay and after delay.
also output is same wen I run the code every time.
what could be wrong?
The field st_atime is changed by file accesses, for example, by execve(2), mknod(2), pipe(2), utime(2) and read(2) (of more than zero bytes). Other routines, like mmap(2), may or may not update st_atime.
While you run “python test.py”, it won’t call read(2), instead it would call mmap(2). That’s why the access time didn’t be udpated.
Here is output of “strace python test.py”