首页 > 解决方案 > 使用 fswatch 和 rsync 自动同步目录时找不到文件

问题描述

我正在使用 fswatch 和 rsync 在 Mac 和 ubuntu 服务器之间自动同步目录。外壳就像

/Users/david/Documents/code/shell/fswatch_rsync.sh:

#!/bin/bash
sudo fswatch -o /Users/david/Documents/code/python/ | xargs -n1 /Users/david/Documents/code/shell/rsync_shell.sh

/Users/david/Documents/code/shell/rsync_shell.sh:

sudo rsync -vzrp --delete /Users/david/Documents/code/python/ --password-file=/etc/rsyncd.pass -e "ssh -i /Users/david/.ssh/id_rsa -p 22" 192.168.0.109::python

但是,当我bash /Users/david/Documents/code/shell/fswatch_rsync.sh在终端中运行并更改中的文件时/Users/david/Documents/code/python/,它会响应:

xargs: ‎⁨/Users/david/Documents/code/shell/rsync_shell.sh: No such file or directory

在终端。

标签: bashshellrsyncfswatch

解决方案


推荐阅读