Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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.

share|improve this question

marked as duplicate by jasonwryan, manatwork, warl0ck, Stéphane Chazelas, Caleb Nov 2 '12 at 12:10

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

@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
@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

2 Answers 2

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

share|improve this answer

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) \;
share|improve this answer

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