A shell script that keeps running rsync in a loop until a file is created to stop it. Obviously not the right way to do such things, but good enough for a quickie.
#!/bin/sh
while :
do
if [ -f '/tmp/stoprsync' ]; then
echo `date` >> /tmp/stoprsync
printf 'found /tmp/stoprsync, exiting now\n'
exit
fi
rsync -avP --stats remote_host::rsync_module /local/dir >> rsyncloop.log
printf "exit code: $?\n\n" >> rsyncloop.log
TRANSFERED=`tail -n 15 rsyncloop.log | grep "files\ transferred" | sed 's/^.*\:\ //'`
printf "TRANSFERED: $TRANSFERED.\n"
if [ "$TRANSFERED" == 0 ]; then
# nothing was transfered the last run, sleep for 5 minutes
sleep 300
else
# no stress
sleep 3
fi
done
Create /tmp/stoprsync to stop it. rsync --status
is needed in order to check if any files were transferred the previous run.