需要在 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.secretsts:1234. 在 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, 内容为对应用户的密码1233. 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 秒运行一次

本文介绍了一种在Windows环境下编写代码,并通过rsync工具与Linux系统进行高效同步的方法。主要步骤包括:在Windows上安装配置cwRsyncServer,设置rsyncd.conf文件,创建密码文件并调整权限;在Linux端编写并定时执行rsync脚本实现自动化同步。
8647

被折叠的 条评论
为什么被折叠?



