相信各位Linux系统管理员经常接触到以下三种时间,ctime改变时间(change time)、mtime修改时间(modification time)、atime访问时间(access time),它们三个有什么区别呢?我们又该如何去对待它们呢?首先我们需要知道如何查看相应的时间:ll -c 查看ctimell 查看mtimell -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 chaoxichaoxi[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 0CentOS root口令丢失处理CentOS 5.5 手动安装 GCC4.6.2相关资讯 linux系统配置
- 配置一个超好用的Linux系统 (12/18/2015 12:08:35)
| - 独立服务器linux系统ftp帐户与 (06/03/2007 06:33:15)
|
本文评论 查看全部评论 (0)