bozosync.sh
Hmm, if you only want to move the changed files, why would the tar command be updating the archive? If only changed files are being sent, wouldn't the tar archive consist only of them, and so be necessarily recreated from scratch each time?
If I'm understanding this correctly you want something like this, I call it bozosync.sh
:
TarFile=fun.tgz
TheScript=$0
result=
ls -1 . | (
while read f; do
if [ -f "$f" -a $f -nt $TheScript ]; then
result="$result $f"
fi
done
tar cvfz $TarFile $result
touch $TheScript
)
This puts every plain file in the current directory in the tar archive, for each file that is newer than the script itself, and then it runs touch(1)
on the script to update its mod time. This does have a race condition, in that a file that is modified in between the test and the touch will be ignored the next time around. If this is a problem you could get around that by copying the script prior to the loop, and then moving it back to itself at the end. (Then you still have a race but the failure is softer, it may simply include a file that hasn't really changed.)