Thursday, March 17, 2011

How to resume partially downloaded files in Linux with wget


Introduction

Resuming interrupted downloads is too important in some areas where the internet is not as stable as it could be in U.S. or Europe.
I find myself usually having interrupted downloads in the Hotels, usually wifi hot spots radios in hotels, are not well installed, I have found some of them with the radiation lobe parallel to the walls and not to the floor of the building, go figure!.
Well, so it is really frustrating to be 40% or 70% of a 300 MByte file downloaded, and that suddenly the Internet goes, even for 2 or 3 minutes, and then you have to restart the download of the file.
Well, no more, wget will help you on that.

Resume partial downloaded files with wget

First be sure to always use the -c option in wget, that way you will be accustomed to it, and will not erase your partially downloaded file with a new one.
As an example, let’s download Gentoo Linux
wget -c http://distfiles.gentoo.org/releases/x86/autobuilds/current-iso/install-...
Now, if we interrupt the download of the file, and run the command again.
wget -c http://distfiles.gentoo.org/releases/x86/autobuilds/current-iso/install-...
You will get something like this, where clearly you can se that the download is being resumed from the point it was interrupted.
bash-4.1$ wget -c http://distfiles.gentoo.org/releases/x86/autobuilds/current-iso/install-...
--2011-03-09 10:45:42--  http://distfiles.gentoo.org/releases/x86/autobuilds/current-iso/install-...
Resolving distfiles.gentoo.org (distfiles.gentoo.org)... 216.165.129.135, 64.50.236.52, 137.226.34.42, ...
Connecting to distfiles.gentoo.org (distfiles.gentoo.org)|216.165.129.135|:80... connected.
HTTP request sent, awaiting response... 206 Partial Content
Length: 121139200 (116M), 114139951 (109M) remaining [application/octet-stream]
Saving to: "install-x86-minimal-20110301.iso"

 7% [+++++==>                                                                                              ] 9,630,265   5.69K/s  eta 2h 51m  ^
The “+” signs shows the previously downloaded part, and the “=” signs shows the part being downloaded at this time.

Conclusion

There are other ways to do this, Firefox, Chrome let you pause and resume downloads, but those are not as good as wget at least not to me, as sometimes I’ve seen them fail, where wget later did not.

No comments: