Linux 如何以毫秒为单位获取 ubuntu 文件时间戳
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3805201/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
how to get ubuntu file timestamp in millisecond
提问by user459635
Linux friends, how do you guys get a file timestamp in the resolution of milliseconds in Ubuntu? When I tried the command "stat" on my system, I get:
Linux 的朋友们,你们如何在 Ubuntu 中获得毫秒分辨率的文件时间戳?当我在我的系统上尝试命令“stat”时,我得到:
File: `tmp.dat'
Size: 14 Blocks: 8 IO Block: 4096 regular file
Device: 811h/2065d Inode: 13895454 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 1000/ yqin) Gid: ( 1004/ dev)
Access: 2010-09-27 09:04:44.000000000 -0400
Modify: 2010-09-25 13:54:58.000000000 -0400
Change: 2010-09-25 13:54:58.000000000 -0400
It seems that the resolution is only up to second. Any ideas? Thanks a lot.
看来分辨率只有秒了。有任何想法吗?非常感谢。
回答by Aaron Digulla
That depends on the filesystem. fat
will give you 2 second resolution. ext2
and ext3
are based on seconds. ext4
has nanoseconds (http://www.softpanorama.org/Internals/Filesystems/linux_ext2_ext3.shtml, search for "minimum timestamp resolution").
这取决于文件系统。fat
会给你 2 秒的分辨率。ext2
并且ext3
基于秒。ext4
有纳秒(http://www.softpanorama.org/Internals/Filesystems/linux_ext2_ext3.shtml,搜索“最小时间戳分辨率”)。