Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I started doing backups via rsync to a remote server. This works all fine and good but 40 gig take their time and as I get a dynamic IP it gets interrupted every day. So every morning when I wake up I restart rsync (if I don't forget it).

I could use already a cronjob but I would really like to execute it immediately after it stops. Is there a way to do that?

share|improve this question

2 Answers 2

up vote 4 down vote accepted
#!/bin/bash
while true
do
    echo "your action (e.g., rsync replacing this line)"

    #If clean exit, stop running
    if [[ $? == 0 ]]
    then
        break
    fi

    #speed throttling
    sleep 10
done
share|improve this answer
    
muchas gracias senor –  bresc Nov 20 '12 at 9:44

Yes, whenever the rsync or any command stops or is interrupted in wrong way, it gives a signal, which is Not equal to 0(0 means success, otherwise error).

so just write a script , which checks for command exit status and saves it in a file. then keep checking that file after , say 5 seconds. so as far as the exist status becomes non-zero, restart the rsync and put 0 in exit status manually.. keep going on and on.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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