When does a UNIX directory change its timestamp

前端 未结 4 636
無奈伤痛
無奈伤痛 2020-12-28 12:14

I used \"touch\" on a file, updating the file\'s timestamp but the parent directory\'s timestamp did not change. However, (as expected) when I created a new file within the

相关标签:
4条回答
  • 2020-12-28 12:17

    A Directory is considered as changed when there is any Addition or Deletion of File/Directory inside it. If existing Files/Directories are just getting update than Parent Directory timestamp will not change.

    0 讨论(0)
  • 2020-12-28 12:21

    The timestamp is updated when the data that represents the directory changes. A change in a subdirectory of directory D does not change anything in the representation of D because D only points to the subdirectory, not to what's inside it. On the other hand, creating a file in D changes the block of data on disk that represents D.

    0 讨论(0)
  • 2020-12-28 12:26

    A directory's timestamp is changed when the Directory itself is changed. The directory contains, among other things, a list of the inodes of the files in the directory so when you change the content of the directory by adding or removing files then the Directories timestamp will be updated.

    0 讨论(0)
  • 2020-12-28 12:34

    You can use the stat command to find the modified time, creation time etc of a file/directory. Refer to https://linux.die.net/man/2/stat

    The article states: st_mtime of a directory is changed by the creation or deletion of files in that directory. The st_mtime field is not changed for changes in owner, group, hard link count, or mode.

    0 讨论(0)
提交回复
热议问题