I am trying to see how many times some of the installed applications are being used on a system.
I used in my python script
fileaccesstime=os.path.getatime(os.sep.join([dirpath, filename]))
Some of the applications dont seem to update atime even when accessed. For example, I used python and saw that atime did not change.
From Get last access time of the file? it appears that atime might not get updated because it would call mmap.
Does that mean I can never find the last access time. I am unsure how to proceed to find out the last access for some applications eg. python
You should check this way:
import os, time
print time.ctime(os.stat('my_path/test.txt').st_atime)
OR
(mode, ino, dev, nlink, uid, gid, size, atime, mtime, ctime) = os.stat(file)
print "Last Access: %s" % time.ctime(atime)
I recommend you to check official info at os.stat()
documentation :
To check creation&modification dates
print "Modification Date: %s" % time.ctime(os.path.getmtime(file))
print "Creation Date: %s" % time.ctime(os.path.getctime(file))
OR
(mode, ino, dev, nlink, uid, gid, size, atime, mtime, ctime) = os.stat(file)
print "Modification Date: %s" % time.ctime(mtime)
print "Creation Date: %s" % time.ctime(ctime)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.