0

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?

3
  • 1
    No sane Unix(-like) OS would do that, ever.
    – schaiba
    Feb 20, 2013 at 13:48
  • Try this test: access the file using cat file > /dev/null. Does the modify time change then?
    – derobert
    Feb 20, 2013 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, 2013 at 15:58

2 Answers 2

1

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
1

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 ).

2
  • 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. Feb 21, 2013 at 0:34
  • thanks for the observation. I just corrected the answer to read instead of open.
    – BitsOfNix
    Feb 21, 2013 at 7:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .