Pine Blog

Shell script 实现wget无限重试下载

1.Shell script名称:wget.sh
wget

#!/bin/sh

int_number=1
# for arg in "$*"; do
#        echo "****:" $arg
# done

echo "\nStart wget No." $int_number ":--------------------\n"
wget -c -N -t 100 $*
while [ $? -ne 0 ] 
do
        int_number=$((int_number+1))
        echo "\nStart wget No." $int_number ":--------------------\n"
        wget -c -N -t 100 $*
done

echo "\nWget Successfully:---------------------\n"

2.使用方法

./wget.sh <url>

3.示例

./wget.sh https://content.production.cdn.art19.com/validation=1725583210,154eaf58-7681-54dc-96cd-a3de2ccd3ea8,Rl5P66Bn-pqSMDqcvfJgUYtRmkI/episodes/12dfc942-a7c8-437c-9aca-bbe272b5010a/e8f9f77e9daed4eeec9a3d4dd628bb22f4cad3bc20ad20174ea53814a8d6824f3d6e431c68999d5098712c461ef94d0dcd3967c93c2cc33fe0b279c742fed40c/wd20230922.mp3

Start wget No. 1 :--------------------

--2024-09-05 08:41:44--  https://content.production.cdn.art19.com/validation=1725583210,154eaf58-7681-54dc-96cd-a3de2ccd3ea8,Rl5P66Bn-pqSMDqcvfJgUYtRmkI/episodes/12dfc942-a7c8-437c-9aca-bbe272b5010a/e8f9f77e9daed4eeec9a3d4dd628bb22f4cad3bc20ad20174ea53814a8d6824f3d6e431c68999d5098712c461ef94d0dcd3967c93c2cc33fe0b279c742fed40c/wd20230922.mp3
正在解析主机 content.production.cdn.art19.com (content.production.cdn.art19.com)... 151.101.110.110
正在连接 content.production.cdn.art19.com (content.production.cdn.art19.com)|151.101.110.110|:443... ^C
user@user-Inspiron-15-3511:~/CS-books$ ./wget.sh https://content.production.cdn.art19.com/    validation=1725583210,154eaf58-7681-54dc-96cd-a3de2ccd3ea8,Rl5P66Bn-pqSMDqcvfJgUYtRmkI/episodes/12dfc942-a7c8-437c-9aca-bbe272b5010a/e8f9f77e9daed4eeec9a3d4dd628bb22f4cad3bc20ad20174ea53814a8d6824f3d6e431c68999d5098712c461ef94d0dcd3967c93c2cc33fe0b279c742fed40c/wd20230922.mp3

Start wget No. 1 :--------------------

--2024-09-05 08:43:47--  https://content.production.cdn.art19.com/validation=1725583210,154eaf58-7681-54dc-96cd-a3de2ccd3ea8,Rl5P66Bn-pqSMDqcvfJgUYtRmkI/episodes/12dfc942-a7c8-437c-9aca-bbe272b5010a/e8f9f77e9daed4eeec9a3d4dd628bb22f4cad3bc20ad20174ea53814a8d6824f3d6e431c68999d5098712c461ef94d0dcd3967c93c2cc33fe0b279c742fed40c/wd20230922.mp3
正在解析主机 content.production.cdn.art19.com (content.production.cdn.art19.com)... 146.75.114.110
正在连接 content.production.cdn.art19.com (content.production.cdn.art19.com)|146.75.114.110|:443... 已连接。
OpenSSL: error:0A000126:SSL routines::unexpected eof while reading
无法建立 SSL 连接。

Start wget No. 2 :--------------------

--2024-09-05 08:44:50--  https://content.production.cdn.art19.com/validation=1725583210,154eaf58-7681-54dc-96cd-a3de2ccd3ea8,Rl5P66Bn-pqSMDqcvfJgUYtRmkI/episodes/12dfc942-a7c8-437c-9aca-bbe272b5010a/e8f9f77e9daed4eeec9a3d4dd628bb22f4cad3bc20ad20174ea53814a8d6824f3d6e431c68999d5098712c461ef94d0dcd3967c93c2cc33fe0b279c742fed40c/wd20230922.mp3
正在解析主机 content.production.cdn.art19.com (content.production.cdn.art19.com)... 151.101.110.110
正在连接 content.production.cdn.art19.com (content.production.cdn.art19.com)|151.101.110.110|:443... 失败:连接超时。
重试中。

--2024-09-05 08:47:07--  (尝试次数: 2)  https://content.production.cdn.art19.com/validation=1725583210,154eaf58-7681-54dc-96cd-a3de2ccd3ea8,Rl5P66Bn-pqSMDqcvfJgUYtRmkI/episodes/12dfc942-a7c8-437c-9aca-bbe272b5010a/e8f9f77e9daed4eeec9a3d4dd628bb22f4cad3bc20ad20174ea53814a8d6824f3d6e431c68999d5098712c461ef94d0dcd3967c93c2cc33fe0b279c742fed40c/wd20230922.mp3
正在连接 content.production.cdn.art19.com (content.production.cdn.art19.com)|151.101.110.110|:443... 已连接。
无法建立 SSL 连接。

Start wget No. 3 :--------------------

--2024-09-05 08:52:34--  https://content.production.cdn.art19.com/validation=1725583210,154eaf58-7681-54dc-96cd-a3de2ccd3ea8,Rl5P66Bn-pqSMDqcvfJgUYtRmkI/episodes/12dfc942-a7c8-437c-9aca-bbe272b5010a/e8f9f77e9daed4eeec9a3d4dd628bb22f4cad3bc20ad20174ea53814a8d6824f3d6e431c68999d5098712c461ef94d0dcd3967c93c2cc33fe0b279c742fed40c/wd20230922.mp3
正在解析主机 content.production.cdn.art19.com (content.production.cdn.art19.com)... 146.75.114.110
正在连接 content.production.cdn.art19.com (content.production.cdn.art19.com)|146.75.114.110|:443... 已连接。
无法建立 SSL 连接。

Start wget No. 4 :--------------------

--2024-09-05 08:55:59--  https://content.production.cdn.art19.com/validation=1725583210,154eaf58-7681-54dc-96cd-a3de2ccd3ea8,Rl5P66Bn-pqSMDqcvfJgUYtRmkI/episodes/12dfc942-a7c8-437c-9aca-bbe272b5010a/e8f9f77e9daed4eeec9a3d4dd628bb22f4cad3bc20ad20174ea53814a8d6824f3d6e431c68999d5098712c461ef94d0dcd3967c93c2cc33fe0b279c742fed40c/wd20230922.mp3
正在解析主机 content.production.cdn.art19.com (content.production.cdn.art19.com)... 146.75.114.110
正在连接 content.production.cdn.art19.com (content.production.cdn.art19.com)|146.75.114.110|:443... 已连接。
无法建立 SSL 连接。

Start wget No. 5 :--------------------

--2024-09-05 09:10:59--  https://content.production.cdn.art19.com/validation=1725583210,154eaf58-7681-54dc-96cd-a3de2ccd3ea8,Rl5P66Bn-pqSMDqcvfJgUYtRmkI/episodes/12dfc942-a7c8-437c-9aca-bbe272b5010a/e8f9f77e9daed4eeec9a3d4dd628bb22f4cad3bc20ad20174ea53814a8d6824f3d6e431c68999d5098712c461ef94d0dcd3967c93c2cc33fe0b279c742fed40c/wd20230922.mp3
正在解析主机 content.production.cdn.art19.com (content.production.cdn.art19.com)... 151.101.110.110
正在连接 content.production.cdn.art19.com (content.production.cdn.art19.com)|151.101.110.110|:443... 已连接。
OpenSSL: error:0A000126:SSL routines::unexpected eof while reading
无法建立 SSL 连接。

Start wget No. 6 :--------------------

--2024-09-05 09:12:11--  https://content.production.cdn.art19.com/validation=1725583210,154eaf58-7681-54dc-96cd-a3de2ccd3ea8,Rl5P66Bn-pqSMDqcvfJgUYtRmkI/episodes/12dfc942-a7c8-437c-9aca-bbe272b5010a/e8f9f77e9daed4eeec9a3d4dd628bb22f4cad3bc20ad20174ea53814a8d6824f3d6e431c68999d5098712c461ef94d0dcd3967c93c2cc33fe0b279c742fed40c/wd20230922.mp3
正在解析主机 content.production.cdn.art19.com (content.production.cdn.art19.com)... 146.75.114.110
正在连接 content.production.cdn.art19.com (content.production.cdn.art19.com)|146.75.114.110|:443... 失败:连接超时。
重试中。

--2024-09-05 09:14:25--  (尝试次数: 2)  https://content.production.cdn.art19.com/validation=1725583210,154eaf58-7681-54dc-96cd-a3de2ccd3ea8,Rl5P66Bn-pqSMDqcvfJgUYtRmkI/episodes/12dfc942-a7c8-437c-9aca-bbe272b5010a/e8f9f77e9daed4eeec9a3d4dd628bb22f4cad3bc20ad20174ea53814a8d6824f3d6e431c68999d5098712c461ef94d0dcd3967c93c2cc33fe0b279c742fed40c/wd20230922.mp3
正在连接 content.production.cdn.art19.com (content.production.cdn.art19.com)|146.75.114.110|:443... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度: 2066921 (2.0M) [audio/mpeg]
正在保存至: ‘wd20230922.mp3’

wd20230922.mp3                                   82%[========================================================================>                ]   1.62M  --.-KB/s    剩余 3mwd20230922.mp3                                 82%[=====================================================================>                ]   1.62M  --.-KB/s    用时 17m 51s

缺少“Last-modified”文件头 -- 关闭时间戳标记。
2024-09-05 09:32:36 (1.55 KB/s) - 在 1703813/2066921 字节处发生读取错误 (连接超时)。 重试中。

--2024-09-05 09:32:38--  (尝试次数: 3)  https://content.production.cdn.art19.com/validation=1725583210,154eaf58-7681-54dc-96cd-a3de2ccd3ea8,Rl5P66Bn-pqSMDqcvfJgUYtRmkI/episodes/12dfc942-a7c8-437c-9aca-bbe272b5010a/e8f9f77e9daed4eeec9a3d4dd628bb22f4cad3bc20ad20174ea53814a8d6824f3d6e431c68999d5098712c461ef94d0dcd3967c93c2cc33fe0b279c742fed40c/wd20230922.mp3
正在连接 content.production.cdn.art19.com (content.production.cdn.art19.com)|146.75.114.110|:443... 已连接。
无法建立 SSL 连接。

Start wget No. 7 :--------------------

--2024-09-05 09:36:28--  https://content.production.cdn.art19.com/validation=1725583210,154eaf58-7681-54dc-96cd-a3de2ccd3ea8,Rl5P66Bn-pqSMDqcvfJgUYtRmkI/episodes/12dfc942-a7c8-437c-9aca-bbe272b5010a/e8f9f77e9daed4eeec9a3d4dd628bb22f4cad3bc20ad20174ea53814a8d6824f3d6e431c68999d5098712c461ef94d0dcd3967c93c2cc33fe0b279c742fed40c/wd20230922.mp3
正在解析主机 content.production.cdn.art19.com (content.production.cdn.art19.com)... 146.75.114.110
正在连接 content.production.cdn.art19.com (content.production.cdn.art19.com)|146.75.114.110|:443... 已连接。
OpenSSL: error:0A000126:SSL routines::unexpected eof while reading
无法建立 SSL 连接。

Start wget No. 8 :--------------------

--2024-09-05 09:37:29--  https://content.production.cdn.art19.com/validation=1725583210,154eaf58-7681-54dc-96cd-a3de2ccd3ea8,Rl5P66Bn-pqSMDqcvfJgUYtRmkI/episodes/12dfc942-a7c8-437c-9aca-bbe272b5010a/e8f9f77e9daed4eeec9a3d4dd628bb22f4cad3bc20ad20174ea53814a8d6824f3d6e431c68999d5098712c461ef94d0dcd3967c93c2cc33fe0b279c742fed40c/wd20230922.mp3
正在解析主机 content.production.cdn.art19.com (content.production.cdn.art19.com)... 146.75.114.110
正在连接 content.production.cdn.art19.com (content.production.cdn.art19.com)|146.75.114.110|:443... 失败:连接超时。
重试中。

--2024-09-05 09:39:45--  (尝试次数: 2)  https://content.production.cdn.art19.com/validation=1725583210,154eaf58-7681-54dc-96cd-a3de2ccd3ea8,Rl5P66Bn-pqSMDqcvfJgUYtRmkI/episodes/12dfc942-a7c8-437c-9aca-bbe272b5010a/e8f9f77e9daed4eeec9a3d4dd628bb22f4cad3bc20ad20174ea53814a8d6824f3d6e431c68999d5098712c461ef94d0dcd3967c93c2cc33fe0b279c742fed40c/wd20230922.mp3
正在连接 content.production.cdn.art19.com (content.production.cdn.art19.com)|146.75.114.110|:443... 已连接。
已发出 HTTP 请求,正在等待回应... 206 Partial Content
长度: 2066921 (2.0M),剩余 363108 (355K) [audio/mpeg]
正在保存至: ‘wd20230922.mp3’

wd20230922.mp3                            100%[++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++===============>]   1.97M  95.8KB/s    用时 3.7s  

缺少“Last-modified”文件头 -- 关闭时间戳标记。
2024-09-05 09:39:50 (95.8 KB/s) - 已保存 ‘wd20230922.mp3’ [2066921/2066921])

wget Successfully:---------------------
未经允许不得转载:Pine Blog » Shell script 实现wget无限重试下载

评论 3

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
  1. Just try to use wget sth. download automatically again when downloads failed.

    pine (2024-09-05) 回复
  2. It's a very simple shell script ,but very useful.

    newcomer (2024-09-05) 回复
  3. Hello.
    Embark on a journey filled with fun and rewards. With a variety of games at your fingertips, every play could lead to your next big win! http://itsjackpottime.com

    Valeron83Nic (2025-01-29) 回复

Pine Blog
Anywhere, Anytime
E-mail:59054872@qq.com
苏ICP备15059480号-1