Question

According to: http://www.php.net/manual/en/function.filectime.php

"In most Unix filesystems, a file is considered changed when its inode data is changed; that is, when the permissions, owner, group, or other metadata from the inode is updated."

However, running Debian linux (uname -r: 2.6.26-2-686) when I access and write to a file, say by using PHP's

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

Both the modified time (filemtime) and the change time (filectime) will get updated. It's my understanding that ctime is only changed when the file's preferences are changed (permissions, ownership, name) and not the content itself.

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>";
Was it helpful?

Solution

Nevermind, after reading http://www.kavoir.com/2009/04/linux-the-differences-between-file-times-atime-accessed-time-ctime-changed-time-and-mtime-modified-time.html

It states: "ctime – change time, or the last changed time of the file or directory, whenever you change and update the file such as changing the file ownership or permissions or modifying the file content, the ctime of the file is updated to the current time"

OTHER TIPS

When you change file data -- you change mtime, Since mtime (modification time) is a PART of INODE, so when mtime is changed, file metadata is changed too, hence ctime (change time) is changed too :)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top