Latest News

How to retry connections with wget?

  • Ivan Ivanov
  • Linux
How to retry connections with wget?

If you have very unstable internet connection or you are downloading files as large as 200GB or even less you could experience timeout issue and you would have to start your wget download again which is quite frustrating especially if the download was close to 90%. Of course there is a quick work-around this.


while [ 1 ]; do
wget --retry-connrefused --waitretry=1 --read-timeout=20 --timeout=15 -t 0 --continue
if [ $? = 0 ]; then break; fi; # check return value, break if successful (0)
sleep 1s;
done;

We save this file as download and make sure the file is executable with chmod +x download than execute the script as follow


wget download https://www.unixsys.org/file.zip

This way even if your connection is unstable the download will keep retrying and will complete without stopping and having to start your wget download from scratch.

6 seconds