码迷,mamicode.com
首页 > 其他好文 > 详细

使用touch命令更改atime、mtime

时间:2016-01-20 06:30:00      阅读:150      评论:0      收藏:0      [点我收藏+]

标签:mtime   touch   ctime   atime   

单独使用touch命令可以更新文件的atime、ctime、mtime为此刻

[root@slave ~]# stat profile
  File: "profile"
  Size: 1796          Blocks: 8          IO Block: 4096   普通文件
Device: 803h/2051d    Inode: 528818      Links: 1
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2015-04-12 5:44:56.145265376 +0800
Modify: 2015-04-12 5:44:56.145265376 +0800
Change: 2015-04-12 5:44:56.145265376 +0800

[root@slave ~]# date
2016年 01月 19日 星期二 20:26:30 CST



[root@slave ~]# touch profile
[root@slave ~]# stat profile
  File: "profile"
  Size: 1796          Blocks: 8          IO Block: 4096   普通文件
Device: 803h/2051d    Inode: 528818      Links: 1
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2016-01-19 20:26:38.938555693 +0800
Modify: 2016-01-19 20:26:38.938555693 +0800
Change: 2016-01-19 20:26:38.938555693 +0800


使用命令"touch -a -t [YY]MMDDhhmm[.ss] filename",可以更改文件的atime

[root@slave ~]# touch -a -t 06062222 profile
[root@slave ~]# stat profile
  File: "profile"
  Size: 1796          Blocks: 8          IO Block: 4096   普通文件
Device: 803h/2051d    Inode: 528818      Links: 1
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2016-06-06 22:22:00.000000000 +0800
Modify: 2016-01-19 20:26:38.938555693 +0800
Change: 2016-01-19 20:30:57.160299376 +0800

使用命令"touch -m -t [YY]MMDDhhmm[.ss] filename",可以更改文件的mtime

[root@slave ~]# touch -m -t 2302030933.33 profile
[root@slave ~]# stat profile
  File: "profile"
  Size: 1796          Blocks: 8          IO Block: 4096   普通文件
Device: 803h/2051d    Inode: 528818      Links: 1
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2016-06-06 22:22:00.000000000 +0800
Modify: 2023-02-03 09:33:33.000000000 +0800
Change: 2016-01-19 20:34:38.521678423 +0800

使用命令"touch -c -t [YY]MMDDhhmm[.ss] filename",可以更改文件的atime和mtime
[root@slave ~]# touch -c -t 1111111111.11 profile
[root@slave ~]# stat profile
  File: "profile"
  Size: 1796          Blocks: 8          IO Block: 4096   普通文件
Device: 803h/2051d    Inode: 528818      Links: 1
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2011-11-11 11:11:11.000000000 +0800
Modify: 2011-11-11 11:11:11.000000000 +0800
Change: 2016-01-19 20:35:59.579968164 +0800

touch命令不能修改ctime为指定时间

本文出自 “好大一只葫芦” 博客,请务必保留此出处http://zhuxingye.blog.51cto.com/11121336/1736606

使用touch命令更改atime、mtime

标签:mtime   touch   ctime   atime   

原文地址:http://zhuxingye.blog.51cto.com/11121336/1736606

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!