5 ms·
A simpler (and more efficient) equivalent to this script would be this one-liner: while true; do rsync -azP $PWD/ <remote>:$PWD/; sleep 2; done Or even be
by dansimau 13y ago
A simpler (and more efficient) equivalent to this script would be this one-liner:
while true; do rsync -azP $PWD/ <remote>:$PWD/; sleep 2; done
Or even better: https://code.google.com/p/lsyncd/ https://code.google.com/p/lsyncd/
lsyncd uses inotify/fsevents, meaning you don't have to traverse the filesystem to poll for changes.
- serkanyersen 13y agoNice suggestion. I didn't use inotify because macosx doesn't have it and nodejs equivalents eats too much CPU for some reason. I tried to make it as simple as possible.
- res0nat0r 13y agoThere are some hoops to jump through but I've got lsyncd working on my Mac. I think you have to compile it with fsevents. I think the README actually details what you need to do.
- skimmas 13y agorunning rsync every 2 seconds on a medium/large project might be a little intense since it compares each file looking for changes.
- dspillett 13y agoIt only needs to compare actual file contents if the file properties (dates, size, ownership, rights) have altered with the options used in this example so it would only need to perform directory reads in the case of no such changes. Of course for a very large project this could still be significant, but much less so.