问题
I need to keep my code synchronized with the same code on virtual machine. Is there a way to monitor file changes and automatically call rsync or something like that?
回答1:
Create a shell script that would call inotifywait
then rsync
in a loop, something like:
#!/bin/bash
LOCAL="/path/to/local/dir"
RSYNC_OPTIONS=...
while true
do
inotifywait -r $LOCAL
rsync $RSYNC_OPTIONS
done
inotifywait is part of the inotify-tools package under Ubuntu
来源:https://stackoverflow.com/questions/8165259/automatic-synchronization-via-rsync