rsync 时间比较 - 修改时间比较的精度是多少

gab*_*be. 6 rsync date

我正在使用以下方法与 rsync 进行同步:

rsync --rLvv --times --size-only 

对于我的初始同步。我的想法,现在是使用:

rsync --rLvv --times

同步具有新修改时间的文件。我的问题是在初始 rsync 之后,我在已同步的文件上看到以下修改时间:

远程 $ 统计 6080_04_big.mp4
  文件:`6080_04_big.mp4'
  大小:258788267 块:505448 IO 块:4096 常规文件
设备:903h/2307d inode:862897 链接:1
访问:(0644/-rw-r--r--) Uid:( 2000/ht) Gid:( 2000/ cust)
访问:2010-08-13 10:46:20.000000000 -0700
修改:2010-08-12 17:55:08.000000000 -0700
更改:2010-08-13 10:46:20.205721673 -0700
本地 $ 统计 6080_04_big.mp4
  文件:`6080_04_big.mp4'
  大小:258788267 块:505448 IO 块:4096 常规文件
设备:902h/2306d inode:136015 链接:1
访问:(0664/-rw-rw-r--) Uid:( 506/ admin) Gid:( 506/ admin)
访问:2010-08-12 20:55:01.482104000 -0400
修改:2010-08-12 20:55:08.468122000 -0400
更改:2010-08-12 21:15:06.952810711 -0400

修改时间是“有效”相同的,但只下降到秒。这里比较的分辨率是多少?似乎任何与第二个相同的东西都被认为是相同的,但我找不到任何指定这一点的文档。有人知道他们的头顶吗?

gab*_*be. 9

这是我回答我自己的问题:

rsync 使用 utime() 调用将文件的修改时间设置为 1 秒分辨率。因此,实际上,对于 rsync 检查的时间比较部分,在第二个之前相同的文件被认为是相同的。

  • 警告:如果文件存储在 FAT 文件系统上,则分辨率为 2 秒(文件系统的限制)。使用 --modify-window=1 避免奇怪的行为,这允许 2 秒的差异。 (3认同)

小智 0

来自 rsync 文档 (rsync.1.md):

0.  `--modify-window=NUM`, `-@`

    When comparing two timestamps, rsync treats the timestamps as being equal
    if they differ by no more than the modify-window value.  The default is 0,
    which matches just integer seconds.  If you specify a negative value (and
    the receiver is at least version 3.1.3) then nanoseconds will also be taken
    into account.  Specifying 1 is useful for copies to/from MS Windows FAT
    filesystems, because FAT represents times with a 2-second resolution
    (allowing times to differ from the original by up to 1 second).

    If you want all your transfers to default to comparing nanoseconds, you can
    create a `~/.popt` file and put these lines in it:

    >     rsync alias -a -a@-1
    >     rsync alias -t -t@-1

    With that as the default, you'd need to specify `--modify-window=0` (aka
    `-@0`) to override it and ignore nanoseconds, e.g. if you're copying
    between ext3 and ext4, or if the receiving rsync is older than 3.1.3.
Run Code Online (Sandbox Code Playgroud)