Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

wget - continue on retry

When downloading a file over a problematic connection, wget fails, and retries. However, it retries from zero, throwing away the previously downloaded part of the file.

$ wget https://www.example.com/file
file          8%[========>                                                                                               ]   2,45M  78,9KB/s    in 32s     

2020-04-01 15:09:18 (78,9 KB/s) - Connection closed at byte 2965504. Retrying.

file         97%[====================================================================================================>   ]  27,09M  50,8KB/s    in 7m 12s  

2020-04-01 15:16:31 (64,3 KB/s) - Connection closed at byte 28409856. Retrying.

file          3%[===>                                                                                                    ]   1,09M  23,2KB/s    in 48s     

and so on

How do I get it to restart from where it got to, instead of starting from zero? I tried wget -c --retry-connrefused, but got the same behavior.

like image 527
MrMartin Avatar asked Feb 24 '26 04:02

MrMartin


1 Answers

I stumbled upon this question in search of a way to handle progressive downloads and here's the command I used to workaround my issue.

wget --continue --progress=dot:mega --tries=0 <url>

The continue option tells wget to try and restart any downloads where they left off. The progress option indicates 3MB per line of dots rather than 384k; appropriate for a file of my size ~1GB. And finally, tries=0 means keep trying forever regardless of how many times the connection fails. If the server closes the connection unexpectedly or you lose connectivity you can easily re-run the command to download where you left off. Hopefully, this works for your use case as well.

like image 107
bgreen Avatar answered Feb 26 '26 17:02

bgreen



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!