On Sun, Mar 04, 2001 at 02:20:21PM -0500, MaD dUCK wrote: > hey, wondering if anyone can help me out... not using anything but > scripting methods, how could i check a file system subtree for > changes? i need "immediate rsync", so ideally the script > "trigger-on-change" would operate like: > > while true; do > trigger-on-change ~/data > # trigger-on-change returns only if there is a change to a file, a > # new file, or a file deleted in the subtree rooted at ~/data. > rsync -avzutC -e ssh --progress --delete ~/data/ $dest > done > > any ideas?
perl! well, `find` can search based on modified timestamp, so that'll get you part way; but knowing WHICH file was deleted, there you've got to keep track of which files USED TO exist, and compare with what's actually there. you can still optimize that a bit by checking directory change times; if it's not been twiddled since your last iteration, then no new files have been created, and no old files have been zapped. existing files may still have been munged, which is why you'd check the modified timestamp on each file, too. now--if you have filesystem access to both source and destination locations, you could use an implementation of a neat script that userland frontier (written in usertalk, easy to translate to perl or maybe even bash) came out with called 'file.reconcileFolder' that's one of the most elegant instances of recursion i've seen. it walks the destination tree looking for files that don't exist on the source (for removal) and walks the source tree looking for files that don't exist on the destination (or are newer). lemme know if you'd like to see frontier's "file.reconcileFolder" script. -- It is always hazardous to ask "Why?" in science, but it is often interesting to do so just the same. -- Isaac Asimov, 'The Genetic Code' [EMAIL PROTECTED] http://groups.yahoo.com/group/newbieDoc -- we need your brain! http://www.dontUthink.com/ -- your brain needs us!