需要在 win 下編寫代碼, 在 Linux 上進行調試. 採用 rsync 來進行同步. 以下為部署過程.
win
1. 下載和安裝 cwRsycServer , 安裝目錄為 Dir .
2. 修改 Dir 下的 rsyncd.conf 為
uid = 0gid = 0use chroot = falsestrict modes = falsehosts allow = *log file = rsyncd.log# Module definitions# Remember cygwin naming conventions : c:\work becomes /cygwin/c/work#[test]path = /cygdrive/e/project/testread only = falsetransfer logging = yesauth users = tssecrets file = rsyncd.secrets
3. 在 Dir 下建立 rsyncd.secrets
ts:123
4. 在 cmd 環境中, 使用 Dir/Bin/chmod.exe 修改 rsyncd.secrets 許可權為 600
5. 運行 Dir/Bin/ 下的 PrepUploadDir.exe
5. 啟動 RsyncServer 服務
Linux
1. 建立 rsync_test.sh
#!/bin/shpass_file=/home/rsync_passif [ -f $pass_file ]then rsync -rv ts@10.1.14.59::test --password-file=$pass_file /home/project/ fiexit 0
2. 建立 /home/rsync_pass, 內容為對應使用者的密碼
123
3. chmod 600 /home/rsync_pass
4. 運行 "crontab -e" 添加
#sync pwvs source code between win and linux* * * * * /home/do/rsync_test.sh > /dev/null 2>&1* * * * * sleep 20; /home/do/rsync_test.sh > /dev/null 2>&1* * * * * sleep 40; /home/do/rsync_test.sh > /dev/null 2>&1
使同步指令碼每隔 20 秒運行一次