Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I'm trying to download a large 2GB file with wget, but after a few minutes it seems to keep stalling.

I ^C it, and wget it again [with --continue option], and it starts downloading again.

Is there a way to automate retrying the download when it stops downloading? Thanks

share|improve this question
1  
thanks heaps great answer man thanks just what I needed. –  name Jun 14 at 6:34

1 Answer 1

up vote 7 down vote accepted

You could use the --tries option.

   --tries=number
       Set number of retries to number.  Specify 0 or inf for infinite
       retrying.  The default is to retry 20 times, with the exception of
       fatal errors like "connection refused" or "not found" (404), which
       are not retried.

So --tries=0 should do the trick.

That, combined with --read-timeout=seconds too. The seconds refers to idle time: if, at any point in the download, no data is received for more than the specified number of seconds, reading fails and the download is restarted.

So the final command:

wget --tries=0 --read-timeout=20 [URL]

share|improve this answer
    
The problem is that wget doesn't quit. It just keeps "downloading" at 0KB/s.. :( –  Matt Oct 27 '11 at 2:56
5  
Ok. Probably you could use --read-timeout=seconds instead. The "time" of this timeout refers to idle time: if, at any point in the download, no data is received for more than the specified number of seconds, reading fails and the download is restarted. This option does not directly affect the duration of the entire download. Of course, the remote server may choose to terminate the connection sooner than this option requires. The default read timeout is 900 seconds. –  Pablo Zubieta Oct 27 '11 at 3:10
    
Yes! That is it! I must have read this long ago when I read the wget manual [most/all of it], and I went back and couldn't find it. –  Matt Oct 27 '11 at 3:51
    
Thanks Pablo, that is the flag I needed as well. –  g33kz0r Mar 2 '13 at 8:37

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.