I am downloading a large file over the network. while downloading (say at 40%) the underlying machine get disconnected from network and before the curl
quit, the network get connected. But in this situation, curl do not resume the process.
Eventually curls quits.
What are the switches for curl
which will help me to resume this interrupted download ?
EDIT: More explanation to problem
18:43:20 PM SHW@SHW:/tmp # curl http://ip-address.com/BigFile
18:43:40 PM <Downloading in progress>
18:43:50 PM <Downloading in progress>
18:44:10 PM <network get disconnected>
18:44:20 PM <Downloading get stuck>
18:44:30 PM <Network get connected>
18:44:40 PM <DOWNLOAD MUST RESUME NOW> <==
As per above timestamp, I want curl
to resume download before curl
quits the started process. I do not want to re-excute the curl command
Best Answer
you can use
-C -
: resume where the previous download left off--retry 999
: retrying so many times--retry-max-time 0
: prevent it from timing out on retryingor
Update
Explanation :
The exit code curl chucks when a download is interrupted is 18, and
$?
gives you the exit code of the last command in bash. So, while the exit code is 18, keep trying to download the file, maintaining the filename(-O)
.My personal preference would be to use
wget
which has been built specifically for this use case. From the man page:wget
is available for almost all Linux distributions - it probably is already installed on yours. Just usewget
to download the file, it will re-establish the network connection until the file is completely transferred.