Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8179347
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T23:58:52+00:00 2026-06-06T23:58:52+00:00

This question is a continuation of my question in another thread .Since the point

  • 0

This question is a continuation of my question in another thread.Since the point of this question is slightly different,I thought I’d post it as a new question.

I experimented getting accessed time for some files in my linux machine(ubuntu lucid),using python .The idea is to have a function which goes through files in a particular directory,see if they have been accessed in the last 2 minutes,and print only those files which have not been accessed.

For accessing a file ,I defined a readfile() method

def readfile(fname):
    with open(fname) as f:
        ct = f.read()
        print 'read file at:',time.time()
        print 'length of file:',len(ct)

For convenience ,I defined some filenames

f1='/home/me/dev/misc/usedfiles/one.txt'
f2='/home/me/dev/misc/usedfiles/two.txt'
f3='/home/me/dev/misc/usedfiles/three.txt'
f4='/home/me/dev/misc/usedfiles/four.txt'

sothat calling readfile(f1) would access the file one.txt

I defined another function to go through the directory and print those files not accessed in last 2 minutes

def files_not_accessed():
    dirname = '/home/me/dev/misc/usedfiles'
    filenames = os.listdir(dirname)
    filenames = [os.path.join(dirname,filename) for filename in filenames]
    for filename in filenames:
        try:
            last_access = os.stat(filename).st_atime #secs since epoch
        except IOError:
            print 'could not get info about %s' % filename
        else:
            timediff =  time.time()-last_access
            print filename,'  last_access=',last_access
            print filename,'  timediff=',timediff
            if timediff > 2*60:
                print filename,'---older than 2 mts'
        print ''

Initially I ran the function files_not_accessed() and it gave the following output

/home/me/dev/misc/usedfiles/two.txt   last_access= 1341459500.0
/home/me/dev/misc/usedfiles/two.txt   timediff= 11668.9905779
/home/me/dev/misc/usedfiles/two.txt ---older than 2 mts

/home/me/dev/misc/usedfiles/one.txt   last_access= 1341460126.0
/home/me/dev/misc/usedfiles/one.txt   timediff= 11042.990674
/home/me/dev/misc/usedfiles/one.txt ---older than 2 mts

/home/me/dev/misc/usedfiles/three.txt   last_access= 1341459504.0
/home/me/dev/misc/usedfiles/three.txt   timediff= 11664.99072
/home/me/dev/misc/usedfiles/three.txt ---older than 2 mts

/home/me/dev/misc/usedfiles/four.txt   last_access= 1341459510.0
/home/me/dev/misc/usedfiles/four.txt   timediff= 11658.990757
/home/me/dev/misc/usedfiles/four.txt ---older than 2 mts

Now,I ran the readfile(f1) function to read the file one.txt

read file at: 1341471195.88
length of file: 47293

As you can see from output of files_not_accessed() function,the file one.txt was last accessed at 1341460126.0 ,and now it is again read at 1341471195.88 by readfile(f1)

And (immediately)ran the files_not_accessed() function and expected that ,it would not output the file one.txt since it was recently accessed.I expected its last_access time to be 1341471195.88

Strangely,I am again getting the previous output

/home/me/dev/misc/usedfiles/two.txt   last_access= 1341459500.0
/home/me/dev/misc/usedfiles/two.txt   timediff= 11715.1272521
/home/me/dev/misc/usedfiles/two.txt ---older than 2 mts

/home/me/dev/misc/usedfiles/one.txt   last_access= 1341460126.0
/home/me/dev/misc/usedfiles/one.txt   timediff= 11089.1273479
/home/me/dev/misc/usedfiles/one.txt ---older than 2 mts

/home/me/dev/misc/usedfiles/three.txt   last_access= 1341459504.0
/home/me/dev/misc/usedfiles/three.txt   timediff= 11711.1273921
/home/me/dev/misc/usedfiles/three.txt ---older than 2 mts

/home/me/dev/misc/usedfiles/four.txt   last_access= 1341459510.0
/home/me/dev/misc/usedfiles/four.txt   timediff= 11705.1274359
/home/me/dev/misc/usedfiles/four.txt ---older than 2 mts

I cannot understand why the file one.txt has last_access= 1341460126.0 instead of the expected 1341471195.88

Any idea why this happens?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T23:58:53+00:00Added an answer on June 6, 2026 at 11:58 pm

    Ubuntu lucid by default mounts filesystems with “relatime”. If you need strict atimes, you need to mount with “strictatime” (at a performance cost).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This question is in continuation to my previous post located here . Since there
This question is an continuation on another StackOverflow post where no clear answer is
This is a continuation of another question about efficiently getting quasi-random numbers. I need
This question is a continuation of a previous thread to compare two lists with
This question is a continuation of this thread : In short: To solve my
This question is in continuation of this post , I have tried installing Xerces-C
This question is in continuation to my existing thread . Below given is a
This is a continuation of another question I have. Consider the following code: char
This question is continuation from my earlier post titled selecting digits from regular expression.
This question is a continuation of my previous question here zend models architecture (big

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.