Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

In Solaris 8, when we access the file, the access time changes but modified time remains same. But in Solaris 10, we see that both access and modified time changes when accessing the file. We checked the at, mt using truss -v lstat -t lstat ls -l <file>.

Is this the behavior of Solaris 10?

share|improve this question
1  
No sane Unix(-like) OS would do that, ever. –  schaiba Feb 20 '13 at 13:48
    
Try this test: access the file using cat file > /dev/null. Does the modify time change then? –  derobert Feb 20 '13 at 14:19
    
I have never seen this in the past and just checked again on Linux and Solaris 10 and Solaris 11 and I still don't see modified time changed on a read/access operation. –  Johan Feb 21 '13 at 15:58

2 Answers 2

Not on UFS or ZFS (or any other standard fs). What are you using to "access" the file? What filesystem are you using?

$ touch test

$ stat test | grep "^[AM]"
Access: (0644/-rw-r--r--)  Uid: (  101/    matt)   Gid: (   10/   staff)
Access: 2013-02-20 13:04:25.597883067 +0000
Modify: 2013-02-20 13:04:25.597883067 +0000

$ cat test

$ stat test | grep "^[AM]"
Access: (0644/-rw-r--r--)  Uid: (  101/    matt)   Gid: (   10/   staff)
Access: 2013-02-20 13:04:38.117719129 +0000
Modify: 2013-02-20 13:04:25.597883067 +0000

$ echo test > test

$ stat test | grep "^[AM]"
Access: (0644/-rw-r--r--)  Uid: (  101/    matt)   Gid: (   10/   staff)
Access: 2013-02-20 13:04:38.117719129 +0000
Modify: 2013-02-20 13:04:54.739753877 +0000

$ cat test
test

$ stat test | egrep "^[AM]"
Access: (0644/-rw-r--r--)  Uid: (  101/    matt)   Gid: (   10/   staff)
Access: 2013-02-20 13:04:59.629405264 +0000
Modify: 2013-02-20 13:04:54.739753877 +0000
share|improve this answer

What you're seeing something is not being done right (Human error). A example: I created a file with vi you will see that at = mt:

truss -v lstat -t lstat ls -l count_files.awk
lstat64("count_files.awk", 0xFFBFF5B8)          = 0
    d=0x04010003 i=58647 m=0100755 l=1  u=0     g=0     sz=674
        at = Feb 20 14:05:56 CET 2013  [ 1361365556.951290423 ]
        mt = Feb 20 14:05:58 CET 2013  [ 1361365558.532478282 ]
        ct = Feb 20 14:05:58 CET 2013  [ 1361365558.532478282 ]
    bsz=1024  blks=3     fs=zfs
-rwxr-xr-x   1 root     root         674 Feb 20 14:05 count_files.awk

Now I will open the file again with vi but exit doing :q!

Notice that at is not equal to mt.

truss -v lstat -t lstat ls -l count_files.awk
lstat64("count_files.awk", 0xFFBFF648)          = 0
    d=0x04010003 i=58647 m=0100755 l=1  u=0     g=0     sz=674
        at = Feb 20 14:07:58 CET 2013  [ 1361365678.550493967 ]
        mt = Feb 20 14:05:58 CET 2013  [ 1361365558.532478282 ]
        ct = Feb 20 14:05:58 CET 2013  [ 1361365558.532478282 ]
    bsz=1024  blks=3     fs=zfs
-rwxr-xr-x   1 root     root         674 Feb 20 14:05 count_files.awk

Now let's make still another test: Open the file with vi and exit but instead of :q! lets do :wq! (although we did not change anything, vi will still save the contents to the file)

truss -v lstat -t lstat ls -l count_files.awk
lstat64("count_files.awk", 0xFFBFF5F8)          = 0
    d=0x04010003 i=58647 m=0100755 l=1  u=0     g=0     sz=674
        at = Feb 20 14:09:26 CET 2013  [ 1361365766.879205630 ]
        mt = Feb 20 14:09:28 CET 2013  [ 1361365768.147368630 ]
        ct = Feb 20 14:09:28 CET 2013  [ 1361365768.147368630 ]
    bsz=1024  blks=3     fs=zfs
-rwxr-xr-x   1 root     root         674 Feb 20 14:09 count_files.awk

As far as I know, at time changes when read is called and modified time when a write is done (write call ).

share|improve this answer
    
The access time changes on read (if the OS doesn't suppress the atime update), not on open. For example, the atime of an empty file doesn't change if you cat it. –  Gilles Feb 21 '13 at 0:34
    
thanks for the observation. I just corrected the answer to read instead of open. –  BitsOfNix Feb 21 '13 at 7:36

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.