Three time properties under Linux

Source: Internet
Author: User

the files under Linux have three time attributes. atime,ctime,mtime, respectively.

Atime:accesstime, which is the file's most recent visit.

CTime:change Time, which is the most recent modification of the file (this is not the create time created). Change refers to a change in the properties of a file, typically modifying file permissions or filenames.

Mtime:Modifytime, which is the most recent modification of the file. Modification means that the contents of a file are changed.

In which, when mtime changes ,ctime must change, and Atime does not necessarily change. When the file content is modified, the file size and other attributes change, and the file CTime changes together. However, there are many ways to modify the file, if it is the direct echo ' Hello ' > file, at this time we have modified the content, but did not view the file, so atime unchanged . If it is a vi file, at this point we have seen the contents of the document, whether you save or not,atime must have changed.

we can view the three properties of the file through the LS command, as follows:

Ls-ul Viewing the atime of a file

LS-CL Viewing the CTime of a file

Ls-l Viewing the mtime of a file

Next, a few tests were conducted to test three times under what circumstances the change would take place.

1.touch A file, then view the file's three time properties.

[[Email protected]]# date2016 May 15 Sunday 01:29:10 cst[[email protected]]# touch file[[email protected]]# ls-u FILE-RW -r--r--. 1root Root 0 May 01:29 file [[email protected] cubix]# ls-c file-rw-r--r--. 1root Root 0 May 01:29 file[[email protected]]# ls-l file-rw-r--r--. 1root Root 0 May 01:29 file

When you can find a touch file, the Atime,ctime, andmtime of the file are the time of touch.

2. View the contents of the file, and then view the file's three time properties.

[Email protected]]# Date

Sunday, May 15, 2016 01:30:33 cst[[email protected]]# cat file[[email protected]]# ls-u file-rw-r--r--. 1root Root 0 May 01:30 file[[email protected]]# ls-c file-rw-r--r--. 1root Root 0 May 01:29 file[[email protected]]# ls-l file-rw-r--r--. 1root Root 0 May 01:29 file

you can seethat after the cat file, the atime of the file changes to Cat time,ctime,mtime is still the touch The time.

3. Modify the contents of the file (directly modify, do not view the contents of the file), then view the file's three time properties.

[[Email protected]]# date2016 May 15 Sunday 01:32:11 Cst[[email protected]]# echo ' hello! ' > File[[email protected]]# ls -U file-rw-r--r--. 1root Root 7 May 01:30 file[[email protected]]# ls-c file-rw-r--r--. 1root Root 7 May 01:32 file[[email protected]]# ls-l file-rw-r--r--. 1root Root 7 May 01:32 file

It can be found that after modifying the contents of the file, the CTimeandmtime of the file becomes the modified time,atime the time when the last view was made.

4. change the file properties, then view the file's three time properties.

[Email protected]]# Date May 15, 2016 01:50:40 cst[[email protected]]# chmod file [[Email Protect ed]]# Ls-lu file-rwx------. 1root Root 7 May 01:30 file[[email protected]]# ls-lc file-rwx------. 1root Root 7 May 01:50 file[[email protected]]# ls-l file-rwx------. 1root Root 7 May 01:32 file

It can be found that after changing the contents of the file, the CTime of the file changes to thetime when the Atime was last viewed, andthe mtime was the time of the last change.

5. Modify the contents of the file (see the contents of the file when modifying), then view the file's three time properties.

[[email protected] cubix]# date2016 May 15 Sunday 02:18:24 Cst[[email protected] cubix]# vi file [[email protected] cubix]# Ls-ul file-rwx------. 1 root root 11 May 02:18 file[[email protected] cubix]# ls-cl file-rwx------. 1 root root 11 May 02:18 file[[email protected] cubix]# ls-l file-rwx------. 1 root root 11 May 02:18 file

It can be found that after modifying the contentsof the file, the Atime, CTime, andmtime of the file become the time when they were modified .


This article comes from "Look back in a year" blog, make sure to keep this source http://cubix.blog.51cto.com/7251166/1773467

Three time properties under Linux

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.