FastNetMon

Tuesday, 11 August 2009

stat: modify и change

У команды stat следующий вывод:

stat `which dir`
File: `/usr/bin/dir'
Size: 90168 Blocks: 192 IO Block: 4096 regular file
Device: ca01h/51713d Inode: 3851868 Links: 1
Access: (0755/-rwxr-xr-x) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2009-08-11 22:48:03.000000000 +0400
Modify: 2009-01-21 09:24:09.000000000 +0300
Change: 2009-07-07 04:07:44.000000000 +0400



я никогда не понимал, чем отличаются Modify от Change, теперь решил разобраться:
Access Time | atime | -ul
This is the time that the file was last accessed, read or written to.

Modify Time | mtime | -l
This is the time that the inode information (permissions, name, etc., the metadata, as it were) was last modified.

Change Time | ctime | -cl
This is the last time the actual contents of the file were last modified.


ВНИМАНИЕ!!! ТУТ Ошибка!!!! Реальное состояние дел уточняйте в моем последнем комменте.

thx http://www.linuxquestions.org/questions/linux-general-1/difference-between-access-modify-change-330250/

4 comments :

  1. This comment has been removed by the author.

    ReplyDelete
  2. Походу там перепутали описание mtime и ctime:
    [mike@vpc52 ~]$ touch test-timestamps
    [mike@vpc52 ~]$ stat test-timestamps

    File: `test-timestamps'
    Size: 0 Blocks: 8 IO Block: 4096 regular empty file
    Device: 902h/2306d Inode: 1169950 Links: 1
    Access: (0664/-rw-rw-r--) Uid: ( 500/ mike) Gid: ( 500/ mike)
    Access: 2009-08-16 02:35:49.000000000 +0400
    Modify: 2009-08-16 02:35:48.000000000 +0400
    Change: 2009-08-16 02:35:48.000000000 +0400

    [mike@vpc52 ~]$ chmod 666 test-timestamps
    [mike@vpc52 ~]$ stat test-timestamps

    File: `test-timestamps'
    Size: 0 Blocks: 8 IO Block: 4096 regular empty file
    Device: 902h/2306d Inode: 1169950 Links: 1
    Access: (0666/-rw-rw-rw-) Uid: ( 500/ mike) Gid: ( 500/ mike)
    Access: 2009-08-16 02:35:49.000000000 +0400
    Modify: 2009-08-16 02:35:48.000000000 +0400
    Change: 2009-08-16 02:36:14.000000000 +0400

    ReplyDelete
  3. Сейчас проверим!

    ReplyDelete
  4. b1:~# cd /tmp
    b1:/tmp# touc suzz
    b1:/tmp# echo 111 > suxx
    b1:/tmp# stat suxx
    File: `suxx'
    Size: 4 Blocks: 8 IO Block: 4096 regular file
    Device: 902h/2306d Inode: 1077346 Links: 1
    Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root)
    Access: 2010-05-24 00:59:59.000000000 +0200
    Modify: 2010-05-24 00:59:59.000000000 +0200
    Change: 2010-05-24 00:59:59.000000000 +0200

    # меняем права на файл
    b1:/tmp# chmod 777 suxx

    Изменился ctime:
    b1:/tmp# stat suxx
    File: `suxx'
    Size: 4 Blocks: 8 IO Block: 4096 regular file
    Device: 902h/2306d Inode: 1077346 Links: 1
    Access: (0777/-rwxrwxrwx) Uid: ( 0/ root) Gid: ( 0/ root)
    Access: 2010-05-24 00:59:59.000000000 +0200
    Modify: 2010-05-24 00:59:59.000000000 +0200
    Change: 2010-05-24 01:00:14.000000000 +0200

    #меняем содержимое файла
    echo 222 >> suxx
    b1:/tmp# stat suxx
    File: `suxx'
    Size: 8 Blocks: 8 IO Block: 4096 regular file
    Device: 902h/2306d Inode: 1077346 Links: 1
    Access: (0777/-rwxrwxrwx) Uid: ( 0/ root) Gid: ( 0/ root)
    Access: 2010-05-24 00:59:59.000000000 +0200
    Modify: 2010-05-24 01:02:25.000000000 +0200
    Change: 2010-05-24 01:02:25.000000000 +0200

    Итого: при измении прав на файл, владельца и проч меняется ctime. А при изменении содержимого и ctime и mtime.

    ReplyDelete

Note: only a member of this blog may post a comment.