Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
up vote 4 down vote accepted
while true
    echo "your action (e.g., rsync replacing this line)"

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

    #speed throttling
    sleep 10
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


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.