Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I want wget to (attempt to) start downloading, then if isn't done after 10 seconds, I want it to give up.

wget --timeout 10 http://url

Seems like a reasonable try, but it seems like it only sets --dns-timeout, --connect-timeout, and --read-timeout. Thus, it could wait 9 seconds for dns, another 9 for connect and then keep downloading forever, as long as data keeps coming at a steady pace (no 10+ second pause).

share|improve this question

2 Answers 2

Basically this will be something like:

wget http://www.somesite.com/file.zip &
PID=$!
sleep 10
if [ `ps ax | grep $PID` -ne '' ]
   then
   kill $PID
fi
share|improve this answer
    
That's one way to solve it, ugly as it is. –  johv Feb 25 '12 at 12:55

This isn't exactly what you're asking as this should only cause Wget to timeout if the download idles for more than 10 seconds:

wget --read-timeout= 10 http://url

About the --read-timeout option, from the Wget 1.13.4 Manual:

Set the read (and write) timeout to seconds seconds. 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.

share|improve this answer

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.