函数mtime linux 分钟,linux 下mtime,ctime,atime分析

一、atime、ctime与mtime

atime是指access time,即文件被读取或者执行的时间,修改文件是不会改变access time的。网上很多资料都声称cat、more等读取文件的命令会改变atime,但是我试验时却发现使用cat、more时atime没有被修改。这个问题需要另外做研究探讨。

ctime即change time文件状态改变时间,指文件的i结点被修改的时间,如通过chmod修改文件属性,ctime就会被修改。

mtime即modify time,指文件内容被修改的时间。

使用stat可以查看文件的atime、ctime、mtime。

atime:access time文件被访问的最后时间。

mtime:modify time文件内容被修改的时间。

ctime:change time文件的inode内容修改的时间。

这样还是不容易理解,如果从英文解释中的函数来理解就容易分清了。例如atime中有提到execve(2)和read(2)函数,其实就是表示文件执行和读取时该时间被修改;mtime中的write(2)就表示内容写入时该时间被修改;ctime中的owner和group表示修改文件所属用户和用户组时该时间被修改。

ls -l filename  看到时间的是mtime

ls -lu filename  看到时间是atime

ls -lc  filename 看到的时间是ctime

英文解释:

Unix filesystems store a number of timestamps for each file. This means that you can use these timestamps to find out when any file or directory was last accessed (read from or written to),  changed (file access permissions were changed) or modified (written to).

atime – File Access Time

Access time shows the last time the data from a file was accessed – read by one of the Unix processes directly or through commands and scripts.

ctime – File Change Time

ctime also changes when you change file's ownership or access permissions. It will also naturally highlight the last time file had its contents updated.

mtime – File Modify Time

Last modification time shows time of the  last change to file's contents. It does not change with owner or permission changes, and is therefore used for tracking the actual changes to data of the file itself.

Timestamps are shown when using the long-format output of ls command, ls -l:

ubuntu# ls -l /tmp/file1

-rw-r--r-- 1 greys root 9 2008-04-05 07:10 /tmp/file1

This is the default output of ls -l, which shows you the time of the last file modification – mtime. In our example, file /tmp/file1 was last changed around 7:10am.

If we want to see the last access time for this file, atime – you need to use -lu options for ls. The output will probably show some later time:

ubuntu# ls -lu /tmp/file1

-rw-r--r-- 1 greys root 9 2008-04-05 07:27 /tmp/file1

In the example, it's 7:27am.

Lastly, ls -lc will show you the last time our file was changed, ctime:

ubuntu# ls -lc /tmp/file1

-rw-r--r-- 1 greys root 9 2008-04-05 07:31 /tmp/file1

$ stat test.txt

File: `test.txt'

Size: 2648461 Blocks: 5176 IO Block: 4096 regular file

Device: fd00h/64768dInode: 1050409 Links: 1

Access: (0644/-rw-r--r--) Uid: ( 666/autosysadmin) Gid: ( 666/autosysadmin)

Access: 2017-06-15 14:23:42.761508546 +0800

Modify: 2017-06-15 14:17:26.737508925 +0800

Change: 2017-06-15 14:23:32.946508404 +0800

touch命令可以修改atime,mtime  具体使用可以man touch

mtime,ctime,atime

mtime,ctime,atime是linux三个主要的变动时间. 这三个时间比较容易理解,但是不容易记忆,也容易搞混. mtime (modification time)  文件内容数据更改时,会更 ...

linux下常用的日志分析命令

linux下常用的日志分析命令   本文介绍下,在linux中常用的一些分析日志的命令行或脚本,有需要的朋友参考下.     形如下面这样的access.log日志内容: 211.123.23.133 ...

linux下find命令-atime,-ctime,-mtime真正含义

linux下的-atime,-ctime,-mtime含义我们经常会在论坛或者群里面被问到,在linux或者unix下如何查看某文件的创建日期?经常又会有人说用find命令加选项-ctime,其实这里 ...

Linux的find命令实例详解和mtime ctime atime

这次解释一下三个Linux文件显示的三个时间,然后展示一下find命令的各个功能 在linux操作系统中,每个文件都有很多的时间参数,其中有三个比较主要,分别是ctime,atime,mtime mo ...

Linux下 USB设备驱动分析(原创)

之前做过STM32的usb HID复合设备,闲来看看linux下USB设备驱动是怎么一回事, 参考资料基于韦东山JZ2440开发板,以下,有错误欢迎指出. 1.准备知识 1.1USB相关概念: USB ...

Java文件夹操作,判断多级路径是否存在,不存在就创建(包括windows和linux下的路径字符分析),兼容Windows和Linux

兼容windows和linux. 分析: 在windows下路径有以下表示方式: (标准)D:\test\1.txt (不标准,参考linux)D:/test/1.txt 然后在java中,尤其使用F ...

linux下常见的性能分析工具

转载于:http://bian5399.blog.51cto.com/3848702/834715 性能调优的主要目的是使系统能够有效的利用各种资源,最大的发挥应用程序和系统之间的性能融合,使应用高效 ...

linux下libpcap抓包分析

一.首先下载libpcap包http://www.tcpdump.org/#latest-release 然后安装,安装完成后进入安装根目录的tests文件夹,编译运行findalldevstest. ...

Linux下库打桩机制分析 function Interposition

[时间:2017-08] [状态:Open] [关键词:linux, libray,打桩,interposition,函数替换,链接器,gcc,malloc,free] 0 引言 本文主要参考< ...

随机推荐

去除inline-block元素间间距的N种方法

这篇文章发布于 2012年04月24日,星期二,22:38,归类于 css相关. 阅读 147771 次, 今日 52 次 by zhangxinxu from http://www.zhangxin ...

HTML页面加载和解析流程详细介绍

浏览器加载和渲染html的顺序 1. IE下载的顺序是从上到下,渲染的顺序也是从上到下,下载和渲染是同时进行的. 2. 在渲染到页面的某一部分时,其上面的所有部分都已经下载完成(并不是说所有相关联的元 ...

gnuplot使用

直接用yum安装gnuplot即可,例如 sudo sh -c "yum install gnuplot.x86_64 " 安装以后就可以使用了 编写gnuplot脚本 # grp ...

032数值的整数次方&lpar;keep it up&rpar;

剑指offer中题目:http://ac.jobdu.com/problem.php? pid=1514 题目描写叙述: 给定一个double类型的浮点数base和int类型的整数exponent. ...

创建Chromium WebUI接口

转载自:http://www.chromium.org/developers/webui Chrome的WebUI是那种,在Chrome中输入 "chrome://xxxx"就能打 ...

font-face 使用

python 小脚本升级-- 钉钉群聊天机器人

一则小脚本(工作中用) 在这篇文章中写的监控的脚本,发送监控的时候 是利用的邮箱,其实在实际,邮箱查收有着不方便性,于是乎升级, 我们工作中,经常用钉钉,那么如果要是能用到钉钉多好,这样我们的监控成功 ...

BZOJ&period;4144&period;&lbrack;AMPPZ2014&rsqb;Petrol&lpar;Kruskal重构树&rpar;

BZOJ 看别人代码的时候发现哪一步都很眼熟,突然想起来,就在四个月前我好像看过还给别人讲过?mmp=v= 果然不写写就是容易忘.写了好歹忘了的时候还能复习呢(虽然和看别人的好像也没多少差别?). 首 ...

JS函数、变量作用域

函数参数 函数的()中指定一个或多个形参(形式参数),多个形参之间用,号隔开,声明形参相当于在函数内部声明了对应的变量,但不赋值.在调用时在()中指定实参  调用时解析器不会检查实参类型.数量,实参可 ...

【POJ1734】Sightseeing Trip 无向图最小环

题目大意:给定一个 N 个顶点的无向图,边有边权,如果存在,求出该无向图的最小环,即:边权和最小的环,并输出路径. 题解:由于无向图,且节点数较少,考虑 Floyd 算法,在最外层刚开始遍历到第 K ...

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值