Detailed explanation of the meaning of ctime atime mtime for files and folders under Linux

  
 

First you can use the stat command to query the inode information of the file, including ctime atime mtime

1. The file is easy to understand:

Access time of the file, atime is reading the file Or any access to the inode that was changed while executing the file will change it here. The modified time of the file, mtime, is changed as the contents of the file are changed when the file is written. The change time of the file, ctime, is changed as the content of the Inode changes when the file is written, the owner, permission, or link settings are changed. As long as the content of stat changes, it will change. The change in mtime will inevitably lead to a change in ctime.

2. Folder:

Access time of the folder, atime is changed when reading the file or executing the file (we only cd into a directory and then cd.. will not cause Atime changes, but ls is different.) The modified time of the folder, mtime is the new file in the folder, *** will change (if you just change the contents of the file will not cause mtime changes, in other words if the result of ls -f <directory> occurs Changing mtime will be refreshed. Someone may argue here: I entered the dd folder vi and then quit, the results of ls -f <directory> have not changed but the mtime of the folder has changed …&hellip This point please the vi command will generate a ”.file.swp” temporary file in this folder when editing the file, the file is ***…… with the exit of vi; this leads to mtime The change [Auxten:p] does not believe you can use nano to modify the file to test). The change time of the folder, ctime is basically the same as the ctime of the file, which reflects the change time of the inode.

Add a little more here: mount -o noatime (mount -o remount, atime /can re-mount the root directory online) can choose not to record the file's atime change, what does this mean? When you create this file, the atime of this file is fixed, unless you use touch or touch -a to force the atime of the file to be refreshed. This can improve the read and write performance of the file system to a certain extent, especially in the system of this kind of website, adding noatime to fstab is a good idea O(∩_∩)O

such as my /dev /sda3 /ext3 noatime 0 1

Copyright © Windows knowledge All Rights Reserved