0

I run rsync as a cron job within a script. Sometimes transfer speed falls down and my large files (say over 1G) take so long to transfer and this stops my script functionality. Is there a way I can tell rsync to stop sending a file if it takes more than n minutes?

In other words, I want to run a rsync command to send a large file to my remote machine. If the transfer finished successfully before n minutes, good to go. If it did not I want rsync give up and continue running the rest of script.

PouJa
  • 35
  • 6

1 Answers1

1

I found out that this is what is timeout command intended to do. If you want to let the main command communicate with the terminal you need to pass --foreground switch.

timeout --foreground 300 rsync ./local_file user@server:/remote/file

This will terminate rsync after 5 minutes.

PouJa
  • 35
  • 6