So I'm trying to make a script that watches for files that haven't been modified for at least 10 seconds then to execute an rsync on the file. My original line was this:
find "/Volumes/Media/" -type f -size +2G -cmin +1 -cmin -60 -exec rsync -aq --update {} /Volumes/LocalMedia/ \;
But that does 1 minute, which is too long. So far I've gotten down to this:
find "/Volumes/Media/" -type f -size +2G -exec bash -c 'echo $(( $(date +%s) - $(stat -f%c "{}") ))' \;
which gives me the output of the files in the directory by seconds. But I seem to be having trouble evaluating that and performing the aforementioned rsync. This is macosx so it's bsd find not GNUfind.
Any thoughts/help would be lovely.
Thanks, -N
You should be able to accomplish this using mtime
:
find "/Volumes/Media/" -type f -size +2G -mtime +10s -exec rsync -aq --update {} /Volumes/LocalMedia/ \;
Using -mtime +10s
would return to find
only files older than 10 seconds