pie*_*iec 3 linux filesystems ext4 date
在我的 linux 系统上,如果我显示当前日期“t1”,请触摸文件“f”,然后显示该“f”的修改时间“t2”,我希望 t1 < t2。
但是当我在我的系统上执行它时,这并不是我总是得到的:
date +'%Y-%m-%d %H:%M:%S.%N'; \
touch f; \
stat -c %y f
Run Code Online (Sandbox Code Playgroud)
示例输出:
2017-09-18 21:47:48.855229801
2017-09-18 21:47:48.853831698 +0200
Run Code Online (Sandbox Code Playgroud)
注意第二个时间戳 (stat) 在第一个 (date) 之前:855229801 > 853831698
我的 fs 是 ext4,但我也尝试在 tmpfs 上使用文件,效果相同。为什么会这样?
谢谢
关于设置的一些信息
% which date
/usr/bin/date
% which touch
/usr/bin/touch
% pacman -Qo /usr/bin/date /usr/bin/touch
/usr/bin/date is owned by coreutils 8.28-1
/usr/bin/touch is owned by coreutils 8.28-1
% uname -a
Linux machine 4.12.12-1-ARCH #1 SMP PREEMPT Sun Sep 10 09:41:14 CEST 2017 x86_64 GNU/Linux
% findmnt
TARGET SOURCE FSTYPE OPTIONS
/ /dev/sda1 ext4 rw,relatime,data=ordered
??/tmp tmpfs tmpfs rw,nosuid,nodev
Run Code Online (Sandbox Code Playgroud)
ext4 文件系统代码调用
current_fs_time()
,它是当前缓存的内核时间被截断为文件系统的超级块中指定的时间粒度,对于 ext4 是 1ns。The current time within the Linux kernel is cached, and generally only updated on a timer interrupt. So if your timer interrupt is running at 10 milliseconds, the cached time will only be updated once every 10 milliseconds. When an update does occur, the accuracy of the resulting time will depend on the clock source available on your hardware.
归档时间: |
|
查看次数: |
1340 次 |
最近记录: |