Wget – automatically resume broken downloads

Wget is a commandline utility to download files over the http protocols. To download a file for example the syntax would be

$ wget http://www.somesite.com/file.zip

The above command will start downloading the file and save it in the home directory of the user. However if the download breaks, due to poor internet for example then wget will stop the download. Now this could be irritating for large downloads when you need to check if the downloading is going on fine.

When the internet is flaky, what happens is that wget tries to connect and when it cant, it thinks that the server is down or does not exist anymore. Therefore we need to tell wget even if the connection is refused.

Here is the simple command

$ wget -c --retry-connrefused --tries=0 --timeout=5 http://www.slax.org/download/7.0.5/slax-English-US-7.0.5-x86_64.iso

The retry-connrefused option tells wget to reconnect even if the earlier connection attempt had failed, so effectively wget will keep connecting everytime the internet goes down and comes up again. This makes automatic download of large files more reliable.

The tries=0 option tells wget to keep trying infinitely.

However even this technique has limitations, for example if the connection exists but data transfer fails, then wget will think that no data is being served and would quit.







Last Updated On : 20th February 2013

Subscribe to get updates delivered to your inbox

1 Comment + Add Comment

  • it keeps on retrying and failing to connect

    but this finally worked for me

    -t 0 –timeout=60 –waitretry=60

Leave a comment