Linux File time attribute and Configuration Modification

Source: Internet
Author: User

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

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.