我正在使用 Unison 在本地 MacBook Pro 和远程服务器之间进行文件同步。同步不一致:有时它工作得很好,但有时它停止检测变化。
Unison 有时无法检测添加到远程目录的新文件,尽管它通常会从本地目录获取更改,但有时即使如此,它也不会。例如,它没有检测到“cs241/a1/a1q5/self-modifying.mips”。我终止了该进程并使用 nohup 脚本重新启动它。这暂时解决了问题,但几分钟后,Unison 再次停止检测远程更改,但本地更改仍然同步。
为什么 Unison 不一致地检测到新文件,以及如何确保它始终检测到更改?
统一版本:2.53.5 配置包括重复=观看实时监控。
任何见解或建议将不胜感激
Unison 2.53.5 (ocaml 5.1.0): Contacting server...
Connected [//local-machine.local//Users/username/uw -> //remote-server//remote/path]
Looking for changes
Waiting for changes from server
Reconciling changes
<---- new file **cs241/a1/a1q5/self-modifying.mips**
1 items will be synced, 0 skipped
0 B to be synced from local to remote-server
36 B to be synced from remote-server to local
Propagating updates
Unison 2.53.5 (ocaml 5.1.0) started propagating changes at 20:43:21.62 on 19 May 2024
[BGN] Copying cs241/a1/a1q5/self-modifying.mips from //remote-server//remote/path to /Users/username/uw
[END] Copying cs241/a1/a1q5/self-modifying.mips
Unison 2.53.5 (ocaml 5.1.0) finished propagating changes at 20:43:21.73 on 19 May 2024, 0.119 s
Saving synchronizer state
Synchronization complete at 20:43:21 (1 item transferred, 0 skipped, 0 failed)
Looking for changes
Waiting for changes from server
Reconciling changes
Nothing to do: replicas have not changed since last sync.
ps aux | grep unison
username 3132 0.0 0.0 410724048 1344 s001 S+ 9:16pm 0:00.00 grep unison
username 3019 0.0 0.1 411474560 12800 s001 SN 8:43pm 0:00.94 /opt/homebrew/Cellar/[email protected]/3.9.19/Frameworks/Python.framework/Versions/3.9/Resources/Python.app/Contents/MacOS/Python /opt/homebrew/bin/unison-fsmonitor
username 3018 0.0 0.0 411175072 4048 s001 SN 8:43pm 0:00.13 ssh -l remoteuser remote.server.com -e none unison -server __new-rpc-mode
username 3011 0.0 0.0 412093776 4832 s001 SN 8:43pm 0:00.32 unison sync.prf
...
#!/bin/zsh
#Define the log file path
LOG_FILE="/Users/username/Library/Application Support/Unison/unison.log"
#Check if a Unison process is already running
if pgrep -f "unison sync.prf" > /dev/null; then
echo "Unison UW Sync process is already running. Exiting."
exit 1
else
#Start the Unison process with nohup
nohup unison sync.prf > "$LOG_FILE" 2>&1 &
echo "Unison UW Sync process started."
fi
#Root directories
root = /Users/username/uw
root = ssh://[email protected]//directory
#Automatically synchronize changes
auto = true
batch = true
repeat = watch
#Ignore dot files
ignore = Name .*
nohup unison sync.prf > /Users/username/Library/Application Support/Unison/unison.log 2>&1 &.
建议检查2台远程机器之间的时间同步。
在 macOS 中,假设 NTP 服务(网络定时协议)正在工作。
在每个主机中运行以下命令:
ntpq -p
这将显示连接到的两台主机中的 NTP 服务器列表,以及远程服务器地址、同步状态、延迟、偏移和抖动等详细信息。如果您的主机与 NTP 服务器同步,您将在输出中看到与其同步的服务器旁边有一个星号 (*)。