The difference between ctime,mtime,atime in Linux

Source: Internet
Author: User

St_atime

Time Whenfile data is last accessed. Changedby the
Following Functions:creat (), Mknod (), pipe (),
Utime (2), Andread (2).

St_mtime
Time Whendata was last modified. Changed bythe fol-
Lowing functions:creat (), Mknod (), pipe (), utime (),
Andwrite (2).

St_ctime
Time Whenfile status is last changed. Changed by the
Following Functions:chmod (), Chown (), creat (),
Link (2), Mknod (), pipe (), unlink (2), Utime (), and
Write ().

The LS shows that the time should be mtime.

Problem description
What is the difference between a file's CTime, Mtime, and atime?
Configuration information
Workaround
The file's Access Time,atime is changed when the file is read or executed.
The Modified time,mtime of a file is changed when the file is written with changes to the contents of the file.
The file's Create Time,ctime is changed as the content of the inode changes when writing to a file, changing owner, permission, or link settings.

As a result, changing the contents of a file changes mtime and CTime, but the CTime of the file may change when the mtime has not changed-in the event that the permissions change, but the contents of the file do not change.
The LS (1) command can be used to list atime, CTime, and mtime of files.
LS-LC filename Lists the CTime of the file
Ls-lu filename Lists the atime of the file
ls-l filename Lists the mtime of the file

   atime does not necessarily have to be modified after accessing the file, because: when using the Ext3 file system, the Atime information is not updated if the Noatime parameter is used on Mount. And this is Noatime canceled, does not represent the actual situation. Anyway, these three time stamp are placed in the inode. If mtime, atime modification, the inode will be changed, since the inode changed, then the CTime will be changed. Using Noatime in Mount option does not want to make too many changes to the file system and improve reading efficiency.

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.