【问题标题】:PHP - linux/unix CTIME (inode change time) is being set when it's only being modifiedPHP - linux / unix CTIME(inode更改时间)仅在修改时设置
【发布时间】:2011-03-20 21:39:04
【问题描述】:

根据:http://www.php.net/manual/en/function.filectime.php

“在大多数 Unix 文件系统中,文件在其 inode 数据发生更改时被视为已更改;也就是说,当 inode 中的权限、所有者、组或其他元数据被更新时。”

但是,当我访问和写入文件时运行 Debian linux (uname -r: 2.6.26-2-686),比如说使用 PHP 的

$fh = fopen($file, 'a');
fwrite($fh, "hello world"); 
fclose($fh);

修改时间 (filemtime) 和更改时间 (filectime) 都会得到更新。据我了解,ctime 仅在文件的首选项(权限、所有权、名称)更改时才更改,而不是内容本身。

clearstatcache();

echo "$file was last changed: " . date("F d Y H:i:s.", filectime($file)). "<br>";
echo "$file was last modified: " . date("F d Y H:i:s.", filemtime($file)). "<br>";
echo "$file was last accessed: " . date("F d Y H:i:s.", fileatime($file)). "<br>";

【问题讨论】:

    标签: php date time ctime


    【解决方案1】:

    没关系,看完http://www.kavoir.com/2009/04/linux-the-differences-between-file-times-atime-accessed-time-ctime-changed-time-and-mtime-modified-time.html

    它声明:“ctime - 更改时间,或文件或目录的最后更改时间,每当您更改和更新文件时,例如更改文件所有权或权限或修改文件内容 ,文件的ctime更新为当前时间"

    【讨论】:

    • 他们在 PHP 定义中并没有很好地解释这一点。
    【解决方案2】:

    当你改变文件数据——你改变了mtime,因为mtime(修改时间)是INODE的一部分,所以当mtime改变时,文件元数据也改变了,因此ctime(改变时间)也改变了:)

    【讨论】:

      猜你喜欢
      • 2013-04-14
      • 2017-03-30
      • 1970-01-01
      • 1970-01-01
      • 2012-01-10
      • 1970-01-01
      • 2021-10-10
      • 2020-11-17
      • 1970-01-01
      相关资源
      最近更新 更多