Bil*_*big 27 linux curl resume-download
我正在curlLinux中工作.我正在ftp服务器下载一个文件的一部分(使用该-r选项),但我的连接不好,它总是中断.我想写一个脚本,当我再次连接时恢复下载.
我已经使用过这个命令了,但它不起作用:
until curl -r 666-9999 -C - --retry 999 -o "path/to/file" "ftp:/path/to/remote/file"; do :; done
Run Code Online (Sandbox Code Playgroud)
Kev*_*RED 35
curl -L -O your_url
Run Code Online (Sandbox Code Playgroud)
这将下载该文件.
现在让我们说你的连接中断;
curl -L -O -C - your_url
Run Code Online (Sandbox Code Playgroud)
这将从下载的最后一个字节继续下载
从联机帮助页:
使用"-C - "告诉curl自动找出恢复传输的位置/方式.然后它使用给定的输出/输入文件来计算出来.
小智 14
wget是专门为这个用例而构建的.从手册页:
Wget has been designed for robustness over slow or unstable network connections;
if a download fails due to a network problem, it will keep retrying until the
whole file has been retrieved. If the server supports regetting, it will
instruct the server to continue the download from where it left off.
Run Code Online (Sandbox Code Playgroud)
wget几乎适用于所有Linux发行版 - 它可能已安装在您的发行版上.只需使用wget下载文件,它将重新建立网络连接,直到文件完全传输.
Cla*_*ani 11
您可以在while循环中检查退出代码并继续,直到退出代码指示下载成功:
export ec=18; while [ $ec -eq 18 ]; do /usr/bin/curl -O -C - "http://www.example.com/a-big-archive.zip"; export ec=$?; done
Run Code Online (Sandbox Code Playgroud)
该示例来自http://ilovesymposia.com/2013/04/11/automatically-resume-interrupted-downloads-in-osx-with-curl/