linux调整文件时间设置,Linux系统文件时间属性及配置修改

相信各位Linux系统管理员经常接触到以下三种时间,ctime改变时间(change time)、mtime修改时间(modification time)、atime访问时间(access time),它们三个有什么区别呢?我们又该如何去对待它们呢?

首先我们需要知道如何查看相应的时间:

ll -c 查看ctime

ll 查看mtime

ll -u 查看atime

我的/tmp目录现在是空的,新建一个文件chaoxi,查看发现三个时间一致

[root@localhost tmp]# ls

[root@localhost tmp]# touch chaoxi

[root@localhost tmp]# ll

-rw-r--r--. 1 root root 0 1月 17 18:40 chaoxi

[root@localhost tmp]# ll -c

-rw-r--r--. 1 root root 0 1月 17 18:40 chaoxi

[root@localhost tmp]# ll -u

-rw-r--r--. 1 root root 0 1月 17 18:40 chaoxi

在/tmp/chaoxi中添加内容,ctime、mtime都发生变化

[root@localhost tmp]# echo "chaoxi" > /tmp/chaoxi

[root@localhost tmp]# ll

-rw-r--r--. 1 root root 7 1月 17 18:41 chaoxi

[root@localhost tmp]# ll -c

-rw-r--r--. 1 root root 7 1月 17 18:41 chaoxi

[root@localhost tmp]# ll -u

-rw-r--r--. 1 root root 7 1月 17 18:40 chaoxi

查看/tmp/chaoxi内容,只有atime变化

[root@localhost tmp]# cat chaoxi

chaoxi

[root@localhost tmp]# ll

-rw-r--r--. 1 root root 7 1月 17 18:41 chaoxi

[root@localhost tmp]# ll -c

-rw-r--r--. 1 root root 7 1月 17 18:41 chaoxi

[root@localhost tmp]# ll -u

-rw-r--r--. 1 root root 7 1月 17 18:41 chaoxi

修改/tmp/chaoxi文件权限,只有ctime变化

[root@localhost tmp]# chmod 755 chaoxi

[root@localhost tmp]# ll

-rwxr-xr-x. 1 root root 7 1月 17 18:41 chaoxi

[root@localhost tmp]# ll -c

-rwxr-xr-x. 1 root root 7 1月 17 18:42 chaoxi

[root@localhost tmp]# ll -u

-rwxr-xr-x. 1 root root 7 1月 17 18:41 chaoxi

到这里我们大致验证了这三个时间的一些变化规律,可以得到一个粗浅的结论:ctime是在写入文件、更改属主、权限或着链接时随Inode的内容更改而变化的;mtime是在写入文件时随文件内容的更改而变化的;atime是在读取文件或者执行文件时变化的。

那么,显而易见这三个时间的变化应该是很频繁的,我现在运维的有一个mysql集群,读写很频繁,可以在/etc/fstab使用noatime、nodiratime两个参数来避免文件系统不断记录文件的访问时间产生的磁盘I/O。如下:

/dev/mapper/VolGrouplv_root / ext4 noatime,nodiratime 0 00b1331709591d260c1c78e86d0c51c18.png

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值