Home » Questions » Computers [ Ask a new question ]

Are file access times not properly maintained in Mac OS X?

Are file access times not properly maintained in Mac OS X?

I'm trying to determine how file access times are maintained by default in Mac OS X, as I'm trying to diagnose some odd behaviour I'm seeing in a new MBP Unibody (running Snow Leopard, 10.6.2):

Asked by: Guest | Views: 57
Total answers/comments: 1
Guest [Entry]

"From man touch (on snow leopard):

Change the modification time of the file. The access time of the
file is not changed unless the -a flag is also specified.

More importantly, it works fine for me:

betelgeuse:tmp james$ touch test
betelgeuse:tmp james$ touch -m -t 200801010000 test2
betelgeuse:tmp james$ touch -a -t 200801010000 test3
betelgeuse:tmp james$ ls -lu test*
-rw-r--r-- 1 james wheel 0 31 Dec 07:41 test
-rw-r--r-- 1 james wheel 0 31 Dec 07:41 test2
-rw-r--r-- 1 james wheel 0 1 Jan 2008 test3
betelgeuse:tmp james$ ls -l test*
-rw-r--r-- 1 james wheel 0 31 Dec 07:41 test
-rw-r--r-- 1 james wheel 0 1 Jan 2008 test2
-rw-r--r-- 1 james wheel 0 31 Dec 07:41 test3
betelgeuse:tmp james$

On the other hand, when I try the same thing in ~ I get the same results as you:

betelgeuse:~ james$ touch test
betelgeuse:~ james$ touch -m -t 200801010000 test2
betelgeuse:~ james$ touch -a -t 200801010000 test3
betelgeuse:~ james$ ls -lu test*
-rw-r--r-- 1 james staff 0 31 Dec 07:42 test
-rw-r--r-- 1 james staff 0 31 Dec 07:42 test2
-rw-r--r-- 1 james staff 0 31 Dec 07:42 test3

The difference? Spotlight doesn't index /tmp, but it does index ~. I'm pretty sure that what you're seeing here is spotlight reading the file to index it after you change the atime - which then sets the atime back to now.

Solution is easy: just add the dirs you don't want indexed to Spotlight's list of folders that shouldn't be indexed.

Just to confirm that this was the case, I made a new dir called ""nospotlight"" and told Spotlight not to index it.

betelgeuse:nospotlight james$ ls -l *
-rw-r--r-- 1 james staff 0 31 Dec 07:47 test
-rw-r--r-- 1 james staff 0 1 Jan 2008 test2
-rw-r--r-- 1 james staff 0 31 Dec 07:47 test3
betelgeuse:nospotlight james$ ls -lu *
-rw-r--r-- 1 james staff 0 31 Dec 07:47 test
-rw-r--r-- 1 james staff 0 31 Dec 07:47 test2
-rw-r--r-- 1 james staff 0 1 Jan 2008 test3

Give Spotlight permission to index it, and mere seconds later:

betelgeuse:nospotlight james$ ls -lu *
-rw-r--r-- 1 james staff 0 31 Dec 07:48 test
-rw-r--r-- 1 james staff 0 31 Dec 07:48 test2
-rw-r--r-- 1 james staff 0 31 Dec 07:48 test3

and once again, modifying the mtime results in an updated atime.

It's definitely Spotlight."