需要在 win 下编写代码, 在 Linux 上进行调试. 采用 rsync 来进行同步. 以下为部署过程.
win
1. 下载和安装 cwRsycServer , 安装目录为 Dir .
2. 修改 Dir 下的 rsyncd.conf 为
uid = 0
gid = 0
use chroot = false
strict modes = false
hosts allow = *
log file = rsyncd.log
# Module definitions
# Remember cygwin naming conventions : c:\work becomes /cygwin/c/work
#
[test]
path = /cygdrive/e/project/test
read only = false
transfer logging = yes
auth users = ts
secrets 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/sh
pass_file=/home/rsync_pass
if [ -f $pass_file ]
then
rsync -rv ts@10.1.14.59::test --password-file=$pass_file /home/project/
fi
exit 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 秒运行一次