Hacker News new | ask | show | jobs
by dansimau 4708 days 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/

lsyncd uses inotify/fsevents, meaning you don't have to traverse the filesystem to poll for changes.

2 comments

Nice 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.
There 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.
running rsync every 2 seconds on a medium/large project might be a little intense since it compares each file looking for changes.
It 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.