Explanation of the meaning of ctime atime mtime in files and folders in Linux

Source: Internet
Author: User

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

1. easy understanding of files:

The access time of the file. atime is any access to inode that 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 Change Time. ctime is changed when the file is written, the owner, permission, or link settings are changed with the inode content. As long as the stat content changes, it will change. A change in mtime will inevitably lead to a change in ctime.

 

 

2. Folder:

The access time of the folder. atime is changed when reading the file or executing the file (we only need to enter one directory for Cd and then CD .. does not cause atime changes, but LS is different ).
The modified time of the folder. mtime is changed only when a file is created or deleted in the folder, in other words, if the result of LS-F <directory> is changed, the mtime will be refreshed. Some people may argue that I entered the DD folder VI and exited. The results of LS-F <directory> are not changed, but the mtime of the folder has changed ...... In this case, the VI command will generate a ". file. SWP" temporary file in this folder during file editing. The file will be deleted as VI exits ...... This leads to a change in mtime [auxten: p]. If you don't believe it, you can use nano to modify the file for testing ).
The change time of the folder is basically the same as the ctime of the file, which reflects the change time of inode.

 

 

Here, we need to add one more point: Mount-O noatime (Mount-O remount, atime/can Remount the root directory online) can choose not to record the atime change of the file. What does this mean? After you create this file, the atime of this file is fixed, unless you use touch or touch-a to force refresh the atime of the file. In this way, the Read and Write Performance of the file system can be improved to a certain extent. In particular, it is a good idea to add noatime to fstab in a website system.

For example, my/dev/sda3/ext3 noatime 0 1

 

Auxten original improper places welcome correction rules: Reprinted with http://hi.baidu.com/auxten

 

========================================================== ======================================

Ls-LC filename: list the file ctime (LS-l -- time = ctime)
Ls-lu filename: list the atime (LS-l -- time = atime) of a file)
Ls-l filename: list the object's mtime (LS-l -- time = mtime)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.