单独使用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为指定时间
转载于:https://blog.51cto.com/zhuxingye/1736606