How to Resume an Interrupted Download Using Curl
This article provides a quick guide on how to resume a failed or
interrupted file download using the curl command-line tool.
You will learn the specific command-line flags required to restart a
download from where it left off, saving both time and bandwidth.
To resume an interrupted file download with curl, use
the -C (or --continue-at) option followed by a
hyphen -. The hyphen tells curl to
automatically determine where to resume the download by looking at the
size of the partially downloaded local file.
The Command Syntax
To resume a download using the original file name, run the following command in your terminal:
curl -C - -O http://example.com/largefile.zip-C -: Automatically finds the offset of the local file and resumes the transfer from that point.-O: Saves the file using its original remote name.
If you originally saved the file under a custom name using the
lowercase -o option, you must specify that same name when
resuming:
curl -C - -o custom_name.zip http://example.com/largefile.zipHow It Works
When you initiate the command with -C -,
curl checks the file size of the local destination file. It
then sends a request to the server asking only for the remaining bytes
starting from that specific offset.
Server Compatibility
For this feature to work, the remote server must support “Byte Range”
requests. Most modern web servers and Content Delivery Networks (CDNs)
support this by default. If the server does not support range requests,
curl will display an error, and the download will have to
be restarted from the beginning.