
我正在使用 rsync 進行一些同步:
rsync --rLvv --times --size-only
對於我的初始同步。我的想法,現在是使用:
rsync --rLvv --次
同步具有新修改時間的檔案。我的問題是,在初始 rsync 後,我在已同步的檔案上看到以下修改時間:
遠端$ 統計 6080_04_big.mp4 文件:“6080_04_big.mp4” 大小:258788267 區塊:505448 IO 區塊:4096 個常規文件 設備:903h/2307d 索引節點: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 索引節點: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
修改時間“實際上”相同,但僅減少到秒。這裡比較的解析度是多少?似乎直到第二秒鐘為止相同的任何內容都被認為是相同的,但我找不到任何指定這一點的文檔。有人知道他們的頭腦嗎?
答案1
這是我回答自己的問題:
rsync 使用 utime() 調用,將檔案的修改時間設為 1 秒解析度。因此,實際上,對於 rsync 檢查的時間比較部分,直到第二秒都相同的檔案被認為是相同的。
答案2
來自 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.