Wget – automatically resume broken downloads

By | February 20, 2013

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.

About Silver Moon

A Tech Enthusiast, Blogger, Linux Fan and a Software Developer. Writes about Computer hardware, Linux and Open Source software and coding in Python, Php and Javascript. He can be reached at [email protected].

One Comment

Wget – automatically resume broken downloads

Leave a Reply

Your email address will not be published. Required fields are marked *