Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've been using rsync to sync a bunch of files between my two servers. I set a cron job that would run rsync every minute. However, I'd prefer if I could have it run always, so that files are synced the moment they are changed. What would be the best way to do this?


share|improve this question
up vote 7 down vote accepted

If you have inotify in your kernel, check out inotify-tools.

There's an example on that page:

# A slightly complex but actually useful example
inotifywait -mrq --timefmt '%d/%m/%y %H:%M' --format '%T %f' \
 -e close_write /home/billy | while read date time file; do
    rsync /home/billy/${file} rsync://${file} && \
    echo "At ${time} on ${date}, file ${file} was backed up via rsync"
share|improve this answer
I'm interested in this solution @Doug. Would you mind explaining what the different parts of this script do? – Amelio Vazquez-Reina Aug 5 '11 at 20:11
FWIW (four years later), lsyncd is a daemon-like program that wraps up this functionality in a very elegant and fairly cross-platform way: – Zac B Sep 17 '13 at 18:28

use the inotify system of linux, in combination with incron.

share|improve this answer
Doug Harris has a nice example usage. Care to further document yours as well? – Nerdling Sep 24 '09 at 21:53
doug copyNpasted the sample direct from that page :) to avoid doing the same: (rtfm) ... it works just like cron, just in a different directory (/etc/incron.d/) – akira Sep 25 '09 at 5:06

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.