zoukankan      html  css  js  c++  java
  • mtime,ctime,atime

    在学习makefile的时候涉及到修改时间,对于mtime,ctime,atime三个时间之间有啥区别呢??

    atime - access time 
    mtime  - if modify time
    ctime  - of change time
    
    ls -lu
    
    To view ctime
    
    ls -lc
    
    To view mtime
    
    ls -lt
    
    文件的 Access time,atime 是在读取文件或者执行文件时更改的。
    文件的 Modified time,mtime 是在写入文件时随文件内容的更改而更改的。
    文件的 Create time,ctime 是在写入文件、更改所有者、权限或链接设置时随 Inode 的内容更改而更改的。 
    

    ls默认显示的时间为mtime

    touch一个文件观察三个时间:

    [root@typhoeus79 20140620]# ls -lc
    total 0
    -rw-r--r-- 1 root root 0 Jun 20 15:32 test
    [root@typhoeus79 20140620]# ls -lu
    total 0
    -rw-r--r-- 1 root root 0 Jun 20 15:32 test
    [root@typhoeus79 20140620]# ls -l
    total 0
    -rw-r--r-- 1 root root 0 Jun 20 15:32 test
    

     echo一个值到这个文件中

    [root@typhoeus79 20140620]# echo 1 >test 
    [root@typhoeus79 20140620]# ls -lc       
    total 4
    -rw-r--r-- 1 root root 2 Jun 20 15:33 test
    [root@typhoeus79 20140620]# ls -lu
    total 4
    -rw-r--r-- 1 root root 2 Jun 20 15:32 test
    [root@typhoeus79 20140620]# ls -l
    total 4
    -rw-r--r-- 1 root root 2 Jun 20 15:33 test
    

     可以看到ctime和mtime都变化了,但是atime没有变化,原因在atime在读取文件或者执行文件时更改

    chmod操作,带来ctime的变化

    -rw-r--r-- 1 root root 3 Jun 20 15:38 test
    [root@typhoeus79 20140620]# ls -l
    total 4
    -rw-r--r-- 1 root root 3 Jun 20 15:38 test
    [root@typhoeus79 20140620]# ls -lc
    total 4
    -rw-r--r-- 1 root root 3 Jun 20 15:38 test
    [root@typhoeus79 20140620]# ls -lu
    total 4
    -rw-r--r-- 1 root root 3 Jun 20 15:38 test
    [root@typhoeus79 20140620]# chmod a+x test 
    [root@typhoeus79 20140620]# ls -lu         
    total 4
    -rwxr-xr-x 1 root root 3 Jun 20 15:38 test
    [root@typhoeus79 20140620]# ls -lc
    total 4
    -rwxr-xr-x 1 root root 3 Jun 20 15:41 test
    [root@typhoeus79 20140620]# ls -l
    total 4
    -rwxr-xr-x 1 root root 3 Jun 20 15:38 test
    

     执行test带来atime的变化

    [root@typhoeus79 20140620]# ls -lu         
    total 4
    -rwxr-xr-x 1 root root 3 Jun 20 15:38 test
    [root@typhoeus79 20140620]# ls -lc
    total 4
    -rwxr-xr-x 1 root root 3 Jun 20 15:41 test
    [root@typhoeus79 20140620]# ls -l
    total 4
    -rwxr-xr-x 1 root root 3 Jun 20 15:38 test
    [root@typhoeus79 20140620]# ./test 
    test
    [root@typhoeus79 20140620]# ls -lu 
    total 4
    -rwxr-xr-x 1 root root 3 Jun 20 15:41 test
    

    http://baliyansandeep.blogspot.jp/2010/02/mtime-ctime-and-atime-timestamp-unic.html

  • 相关阅读:
    uva 408 Uniform Generator
    Java实现 蓝桥杯VIP 算法提高 栅格打印问题
    Java实现 蓝桥杯VIP 算法提高 栅格打印问题
    Java实现 蓝桥杯VIP 算法提高 栅格打印问题
    Java实现 蓝桥杯VIP 算法提高 打水问题
    Java实现 蓝桥杯VIP 算法提高 打水问题
    Java实现 蓝桥杯VIP 算法提高 打水问题
    Java实现 蓝桥杯VIP 算法提高 打水问题
    Java实现 蓝桥杯VIP 算法提高 不同单词个数统计
    Java实现 蓝桥杯VIP 算法提高 不同单词个数统计
  • 原文地址:https://www.cnblogs.com/gsblog/p/3799417.html
Copyright © 2011-2022 走看看