UNIX 目录何时更改其时间戳
我在文件上使用了“touch”,更新了文件的时间戳,但父目录的时间戳没有改变。但是,(如预期)当我在父目录中创建新文件时,该目录的时间戳确实发生了变化。
类 UNIX 操作系统(特别是 AIX)使用什么标准来确定何时更新目录的时间戳?
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 parent directory, the directory's timestamp did change.
What criteria do UNIX-like operating systems (specifically AIX) use to determine when to update the timestamp of a directory?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
当目录内有任何文件/目录的添加或删除时,目录被视为已更改。如果现有文件/目录刚刚获得更新,则父目录时间戳不会改变。
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.
当代表目录的数据发生更改时,时间戳就会更新。目录 D 的子目录中的更改不会更改 D 的表示形式中的任何内容,因为 D 只指向子目录,而不指向其中的内容。另一方面,在 D 中创建文件会更改磁盘上代表 D 的数据块。
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.
当目录本身更改时,目录的时间戳也会更改。该目录除其他外还包含目录中文件的 inode 列表,因此当您通过添加或删除文件来更改目录内容时,目录时间戳将更新。
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.
您可以使用 stat 命令查找文件/目录的修改时间、创建时间等。
参考https://linux.die.net/man/2/stat
文章指出:
目录的 st_mtime 通过在该目录中创建或删除文件来更改。 st_mtime 字段不会因所有者、组、硬链接计数或模式的更改而更改。
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.