Solaris 10 modified time

5,285

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

Solution 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:
5,285

Related videos on Youtube

Mat
Author by

Mat

Updated on September 18, 2022

Comments

  • Mat
    Mat almost 2 years

    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?

    • schaiba
      schaiba over 11 years
      No sane Unix(-like) OS would do that, ever.
    • derobert
      derobert over 11 years
      Try this test: access the file using cat file > /dev/null. Does the modify time change then?
    • Johan
      Johan over 11 years
      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.
  • Gilles 'SO- stop being evil'
    Gilles 'SO- stop being evil' over 11 years
    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.
  • BitsOfNix
    BitsOfNix over 11 years
    thanks for the observation. I just corrected the answer to read instead of open.