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

  • 相关阅读:
    项目踩坑实记 :2019年(SSM 架构)
    多线程实践
    SpringCloud(一)之我学 Eureka
    JVM 第一次学习总结 --- 2019年4月
    《深入理解 JVM 虚拟机》 --- 看书笔记
    JVM 学习(二)Java 内存模型、方法内联、逃逸 --- 2019年4月
    JVM 学习(一)反射、垃圾回收、异常处理--- 2019年4月
    剑指offer-18.树的子结构
    剑指offer-17.合并两个有序链表
    剑指offer-16.翻转链表
  • 原文地址:https://www.cnblogs.com/gsblog/p/3799417.html
Copyright © 2011-2022 走看看