Possible Duplicate:
How to run a command when a directory’s contents are updated?

Any one know how to monitor files in Unix. I want to take backup of that files when its modified and store it in another server.

  • @jasonwryan As far as I know inotify is a GNU/Linux tool. If the OP has some other UNIX this will not work. – qbi Nov 2 '12 at 7:39
  • 1
    @qbi That may be true, but in the absence of any indication as to what OS he is running, I think it reasonable to assume it is Linux. There is an inotify for BSD as well... – jasonwryan Nov 2 '12 at 7:42

rsync can do that, it will copy only changed files. But it requires to be scheduled. It doesn't monitor a file to copy it upon change, rather it checks for changed files every time when run. Your question is not very specific so it is difficult to give a detailed answer, but I have the impression you want to check the man rsync for --include and --exclude. You can schedule a command like this using cron


You would have to run something like Tripwire which would alert you or do an action when it detected a change.

A simpler method would be to use find

find (path to files) -mmin 60 -type f

you can then do something like

find (path to files) -mmin 60 -type f -exec gzip -9 {} \; -exec mv {}.gz_`date +%F`.gz (path to new location) \;

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