I believe that Linux system administrators often have access to the following three types of time: ctime change time, mtime modification time, And atime access time ), what are the differences between them? How should we treat them?
First, we need to know how to view the corresponding time:
Ll-c view ctime
Ll view mtime
Ll-u view atime
My/tmp directory is empty now. Create a new file named "chaoxi" and check that the three directories are consistent.
[Root @ localhost tmp] # ls
[Root @ localhost tmp] # touch chaoxi
[Root @ localhost tmp] # ll
-Rw-r --. 1 root 0 January 17 18:40 chaoxi
[Root @ localhost tmp] # ll-c
-Rw-r --. 1 root 0 January 17 18:40 chaoxi
[Root @ localhost tmp] # ll-u
-Rw-r --. 1 root 0 January 17 18:40 chaoxi
The content added to/tmp/chaoxi changes both ctime and mtime.
[Root @ localhost tmp] # echo "chaoxi">/tmp/chaoxi
[Root @ localhost tmp] # ll
-Rw-r --. 1 root 7 January 17 18:41 chaoxi
[Root @ localhost tmp] # ll-c
-Rw-r --. 1 root 7 January 17 18:41 chaoxi
[Root @ localhost tmp] # ll-u
-Rw-r --. 1 root 7 January 17 18:40 chaoxi
View/tmp/chaoxi content, only atime changes
[Root @ localhost tmp] # cat chaoxi
Chaoxi
[Root @ localhost tmp] # ll
-Rw-r --. 1 root 7 January 17 18:41 chaoxi
[Root @ localhost tmp] # ll-c
-Rw-r --. 1 root 7 January 17 18:41 chaoxi
[Root @ localhost tmp] # ll-u
-Rw-r --. 1 root 7 January 17 18:41 chaoxi
Modify the/tmp/chaoxi File Permission, only ctime changes
[Root @ localhost tmp] # chmod 755 chaoxi
[Root @ localhost tmp] # ll
-Rwxr-xr-x. 1 root 7 Aug 17 18:41 chaoxi
[Root @ localhost tmp] # ll-c
-Rwxr-xr-x. 1 root 7 Aug 17 18:42 chaoxi
[Root @ localhost tmp] # ll-u
-Rwxr-xr-x. 1 root 7 Aug 17 18:41 chaoxi
Here we have roughly verified some of the changes in these three periods, and we can draw a rough conclusion: ctime changes with Inode content when writing files, changing the owner, permissions, or links. mtime changes with file content when writing files; atime changes when reading or executing files.
Then, it is obvious that the changes in these three periods should be very frequent. I am currently operating and maintaining a mysql cluster with frequent reads and writes, the noatime and nodiratime parameters can be used in/etc/fstab to prevent the file system from recording the disk I/O generated by the file access time. As follows:
/Dev/mapper/VolGrouplv_root/ext4 noatime, nodiratime 0 0