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

    mtime   ls -l   显示最近修改文件内容的时间
    atime   ls -lu  显示最近访问文件的时间
    ctime   ls -li  显示最近文件有所改变的状态,如文件修改,属性属主改变,节点,链接变化等
    

    创建三个文件 a b c

    echo "1" > a
    echo "2" > b
    echo "3" > c
    

    执行 ls -l, ls -lu, ls -li 操作, mtime, atime, ctime 都一样

    -rw-r--r--. 1 root root 2 Aug  7 09:50 a
    -rw-r--r--. 1 root root 2 Aug  7 09:50 b
    -rw-r--r--. 1 root root 2 Aug  7 09:50 c
    

    执行 cat a, echo "b" > b 操作

    cat a
    echo "b" > b
    
    # 因 b 的内容改变,mtime(最近修改文件内容的时间) 随之更改
    ls -l
    -rw-r--r--. 1 root root 2 Aug  7 09:50 a
    -rw-r--r--. 1 root root 2 Aug  7 09:51 b
    -rw-r--r--. 1 root root 2 Aug  7 09:50 c
    
    # 因 执行了 cat a 操作,atime(显示最近访问文件的时间) 更改
    ls -lu
    -rw-r--r--. 1 root root 2 Aug  7 09:51 a
    -rw-r--r--. 1 root root 2 Aug  7 09:50 b
    -rw-r--r--. 1 root root 2 Aug  7 09:50 c
    
    # 因 b 的内容改变,ctime(最近文件有所改变的状态) 随之更改
    ls -li
    4195057 -rw-r--r--. 1 root root 2 Aug  7 09:50 a
    4418917 -rw-r--r--. 1 root root 2 Aug  7 09:51 b
    4418918 -rw-r--r--. 1 root root 2 Aug  7 09:50 c
    

    若使用 scp 把文件拷贝到其他机器,mtime, atime, ctime 默认情况下会随之改变,若不想改变,可以在 scp 命令后加上 -p 参数

    man scp
    -p      Preserves modification times, access times, and modes from the original file.
    
  • 相关阅读:
    98.公共汽车
    100.选菜(动态规划)01背包
    102.愤怒的LJF
    96.老鼠的旅行(动态规划)
    95.(01背包)之小吃
    94.Txx考试
    93.数字三角形W(深搜)
    POJ 3352 Road Construction (边双连通分量)
    POJ 3114 Countries in War(强联通分量+Tarjan)
    POJ 3592 Instantaneous Transference(强联通分量 Tarjan)
  • 原文地址:https://www.cnblogs.com/klvchen/p/11313302.html
Copyright © 2011-2022 走看看