如何在curl中自动恢复中断的下载? [英] How to resume interrupted download automatically in curl?
问题描述
我正在Linux中使用 curl
。我正在ftp服务器上下载文件的一部分(使用 -r
选项),但是连接不好,它总是会中断。我想编写一个脚本,当我再次连接时可以继续下载。
I'm working with curl
in Linux. I'm downloading a part of a file in ftp server (using the -r
option), but my connection is not good, it always interrupts. I want to write a script which resume download when I'm connected again.
我使用了此命令,但是它不起作用:
I've used this command, but it's not working:
until curl -r 666-9999 -C - --retry 999 -o "path/to/file" "ftp:/path/to/remote/file"; do :; done
推荐答案
curl -L -O your_url
这将下载文件。
现在,假设您的连接已中断;
Now let's say your connection is interrupted;
curl -L -O -C - your_url
此操作将从下载的最后一个字节继续下载
This will continue downloading from the last byte downloaded
来自手册页:
使用 -C-告诉curl自动找出在哪里/如何恢复传输。然后,它使用给定的输出/输入文件来解决这个问题。
Use "-C -" to tell curl to automatically find out where/how to resume the transfer. It then uses the given output/input files to figure that out.
这篇关于如何在curl中自动恢复中断的下载?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!