使用 cwRsync 从 win 同步代码到 Linux

需要在 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 秒运行一次

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值