Re:Facebook first level interview for Linux admin position
by ciupicri on Saturday September 28, 2013 @08:15PM
(#6463593)
Just to clarify things a bit more, I'll quote from the stat(2) man page [1]:
time_t st_atime; /* time of last access */
time_t st_mtime; /* time of last modification */
time_t st_ctime; /* time of last status change */
The field st_atime is changed by file accesses, for example, by
execve(2), mknod(2), pipe(2), utime(2) and read(2) (of more than zero
bytes). Other routines, like mmap(2), may or may not update
st_atime.
The field st_mtime is changed by file modifications, for example, by
mknod(2), truncate(2), utime(2) and write(2) (of more than zero
bytes). Moreover, 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.
The field st_ctime is changed by writing or by setting inode
information (i.e., owner, group, link count, mode, etc.).
[1]: http://man7.org/linux/man-pages/man2/stat.2.html
ctime is not when the file was created, it's when the inode (the file metadata) was last changed, as compared to the mtime which is when the file's data was last changed. Note that changing the file's data also updates the ctime.