I learned how to get started every day. Yesterday I cheated on the book "unix Super tool" from mmmmn and understood a problem that I had been puzzled for many years. Now I want to share it with you.
When you talk to skilled UNIX users, you often hear the terms "change time" and "modification time" arrogant )". For many (and many dictionaries), changes and modifications are the same. What is the difference here?
The difference between changing and modifying is that you can change the label of a component or its content. If someone says chmod a-w myfile, this is a change; if someone says echo foo >;>; myfile. This is a modification. The change is because the index node of the file has changed, and the modification is because the content of the text has changed. [The file modification time is also called the timestamp.]
As long as we discuss the change time and modification time, we cannot mention the "access time". The access time is the last time the file was read. Therefore, reading a file updates the access time of the file. When the change time does not change (the information about the file is not changed ), the same is true for its modification time (the file itself has not been changed)
Sometimes, in many cases, changing the time or "ctime" is mistakenly written as "creation time", including some UNIX reference manuals. Don't trust them
The following is the content from man. It is for reference only!
St_atime
Time when file data was last accessed. Changed by
Following functions: creat (), mknod (), pipe (),
Utime (2), and read (2 ).
St_mtime
Time when data was last modified. Changed by the fol-
Lowing functions: creat (), mknod (), pipe (), utime (),
And write (2 ).
St_ctime
Time when file status was last changed. Changed by
Following functions: chmod (), chown (), creat (),
Link (2), mknod (), pipe (), unlink (2), utime (), and
Write ().
The time displayed by ls is mtime.
After touch, the file time should change. You can try it.
From HP unix: http://e-support.hp.com.cn/e-del... = 0% 3A89% 3A112% 3A176
Problem description
What is the difference between the ctime, mtime, and atime of a file?
Configuration Information
Solution
The Access time of the file. atime is changed when the file is read or executed.
The Modified time and mtime of the file are changed as the file content changes when the file is written.
File Create time, ctime is changed when the file is written, the owner, permission, or link settings are changed with the Inode content.
Therefore, changing the file content changes the mtime and ctime, but the ctime of the file may be changed when the mtime is not changed-when the permission is changed, but the file content remains unchanged.
The ls (1) command can be used to list the atime, ctime, and mtime of a file.
Ls-lc filename: list the ctime of a file
Ls-lu filename: list the atime of a file
Ls-l filename: list the mtime of a file
Atime may not be modified after the file is accessed, because if the noatime parameter is used during the mount operation when the ext3 file system is used, the atime information will not be updated. This is canceled with noatime. It does not mean the real situation is canceled. all three time stamps are stored in inode. if mtime and atime are modified, inode will be changed. Since inode is changed, the ctime will be changed. the reason why noatime is used in mount option is that you do not want to make too many modifications to file system to improve the efficiency of compaction.