I have a problem with a defective round robin data mover node I'm rsync'ing data from. One of the nodes keeps dropping the data connection to the file system my data is coming from and needs to reconnect, which can take up to several minutes. During this time, the rsync on that particular file does not abort, it just hangs, for up to several minutes, until the download continues. Because this is time critical data, that is not a viable option, but instead should drop the connection asap when it stalls, and reconnect (which would then be load balanced to the next node anyway).

Can anyone think of a method to tell rsync to abort a transfer that's been stalled for more than e.g. 20 seconds?

The operator of the broken data mover nodes are slow to react to this problem, they're aware of it, but not doing anything at the moment, so I need to find a solution at my end.

I've tried using the --timeout option, but that doesn't seem to work when a data connection is stalled.

3 Answers 3


You can run rsync with --timeout=SECONDS to exit after stalled file transfers. More recent versions of rsync have --contimeout=SECONDS for connection timeouts.

# timeout after 20 seconds
rsync --timeout=20 source destination

# timeout after 3 seconds of no connectivity
rsync --contimeout=3 source destination

More helpful example: https://explainshell.com/explain?cmd=rsync+--timeout%3D60+-aP+--append-verify+--stats+user%40host%3A%2Ffolder+%2Fcygdrive%2Ff%2Fbackup


If you have an idea of the max duration for each rsync run, you can use timeout:

$ timeout 120 /usr/bin/rsync <options>
  • Indeed, I've been doing that, but it's not ideal because the rsync wildcard catches such a huge number of files that the individual transfer timeout vs. the full download timeout is in a bad relationship to re-commencing the transfer every time.
    – John
    Feb 27, 2017 at 16:15

What rsync transport are you using? If SSH, then you might be able to pass configuration options to SSH to help you time out your connection. I don't have a good method to test, but maybe the ServerAliveInterval, and TCPKeepAlive options might give you want you need?

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .