How to config wget to retry more than 20?
Asked Answered
M

2

29

I used d4x to continue download, but it's obsolete from ubuntu. So I use flashgot with wget to continue download. But wget stops after 20 tries, I have to restart manually. Is there any conf file I could modify the retry times more than 20?

The wget CLI is automatic created by wget, so please don't tell me I could make options with the wget CLI.

Mcclish answered 11/7, 2015 at 3:57 Comment(2)
Write a loop in bash?Pail
See gnu.org/software/wget/manual/wget.html#Startup-File for info on using the .wgetrc startup file.Outwear
T
71

Use the --tries option:

wget --tries=42 http://example.org/

Specify --tries=0 or --tries=inf for infinite retrying (default is 20 retries).

The default value also can be changed via config file, if that is your thing; open /etc/wgetrc and look there for:

# You can lower (or raise) the default number of retries when
# downloading a file (default is 20).
#tries = 20

uncomment tries=20 and change it to what you want.

The default is to retry 20 times, with the exception of fatal errors like "connection refused" or "not found" (404), which are not retried

Tal answered 11/7, 2015 at 5:17 Comment(1)
Upvoted,but,please also mention that The default is to retry 20 times, with the exception of fatal errors like "connection refused" or "not found" (404), which are not retried. Sylvanus
K
7

If the default retry value can not meet your needs, it seems you are downloading from an unstable source.

The following option may also help a lot.

--retry-connrefused  --read-timeout=20 --timeout=15 --tries=0 --continue

--retry-connrefused Force wget to retry even the server refuses requests, otherwise wget will stop to retry.

--waitretry=1 If you decide to retry many times, it's better to add some short period between each retry.

--timeout=15 unstable link always cause stopping of data flow, the default 900s timeout is too long. There is --dns-timeout, --connect-timeout, and --read-timeout. By specify --timeout, you update them all at the same time.

--tries=0 Make wget to retry infinity except fatal situations such as 404.

--continue resume download

2023-02-28T17:59:32 added

Recently, I found wget will auto exist after severl tries on a very unstable link, with all the options above configured.

So, I come up with a autohotkey script, which will check if wget is still running. If not, it will bring up it again.

; AutoHotkey Version: 1.x
; Language:       English
; Platform:       WinXP/7
; Author:         studotwho
; Url:        https://www.autohotkey.com/board/topic/66615-continuously-check-if-a-program-is-running-and-start-it/
;
; Script Function:
;   Restarts the iTeleportConnect service if it hasn't started - this usually happens if your
;   wireless network interface hasn't started when iTC tries to connect.
;
;   This script loops every (45) seconds to determine if iTC is running or not, and restarts it if it's not.
;

#SingleInstance, force
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

iTC_EXE     = C:\usrprogs\wget-1.19.4-win32\lowspeeddown.bat
iTC_Path    = C:\usrprogs\wget-1.19.4-win32
iTC_imgName = wget.exe

loop {
    sleep 3000
    Process, Exist, %iTC_imgName% ; check to see if iTeleportConnect is running
    If (ErrorLevel = 0) ; If it is not running
       {
       Run, %iTC_EXE%, %iTC_Path%
       }
    Else ; If it is running, ErrorLevel equals the process id for the target program (Printkey). Then do nothing.
       {
        sleep 5
       }
}

2024-02-16T18:47:08

Sorry, I just noticed that the question is about running wget binary by flashgot on a ubuntu system.

Kline answered 5/2, 2022 at 6:57 Comment(1)
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.Lavettelavigne

© 2022 - 2024 — McMap. All rights reserved.