两台android 设备 进行rsync 同步 1。编译 rsync 源码 sudo apt-get install gcc-arm-linux-gnueabi wget http://rsync.samba.org/ftp/rsync/rsync-3.1.0.tar.gz tar -zxv -f rsync-3.1.0.tar.gz cd rsync-3.1.0 ./configure --host=arm-linux-gnueabi CFLAGS="-static" make 2. 将生成的rsync 复制到/system/xin下 这个可以根据需求 到不同的目录下。
配置文件 rsyncd.conf # Distributed under the terms ofthe GNU General Public License v2 # Minimal configuration file for rsyncdaemon # See rsync(1) and rsyncd.conf(5) man pagesfor help # This line is required by the/etc/init.d/rsyncd script pid file = /data/shareData/rsyncd.pid port = 55873 uid = 0 gid = 0 secrets file = /etc/rsyncd/rsyncd.secrets hosts allow = * use chroot = yes read only = no max connections = 5 #This will give you a separate log file log file = /data/shareData/rsync.log log format = %t %a %m %f %b syslog facility = local3 timeout = 300 [test] path = /data/shareData lock file = rsyncd.lock #list=yes hosts allow = * ignore errors secrets file = /etc/rsyncd/rsyncd.secrets auth users = root
密码文件 rsyncd.secrets root:root 密码文件 rsyncd.secrets2 root 以上三个文件都要自己建立 然后复制到/etc 下面 (不同的情况需求放在不同下面) 可能有时候调试回报错因为文件的权限不对,或者不同机子的设置不同 这个遇见问题google好了
运行 启动服务 /system/xbin/rsync --daemon --config=/etc/rsyncd/rsyncd.conf 同步文件 /system/xbin/rsync -avzP --timeout=30 --delete --password-file=/etc/rsyncd/rsyncd.secrets2 [email protected]::test/rsync/ /mnt/sdcard/ 上面的意思是将远端192.168 目录下的/rsync文件的内容 同步到本机 sdcard 以上命令直接可以在 命令行运行 如果要用代码运行在java中 Runtime.getRuntime().exec 相关命令