减少 WGET 下载完成时间
Decrease WGET Download Completion Time
我在 Ubuntu LTS 中使用 wget 程序每天从网络服务器下载一系列文件。最近,此 Web 服务器不堪重负,负责维护它的组织 (NCEP) 似乎已开始限制下载请求的数量和速度。
主要提示:在此之前,wget 能够在 15 分钟内完成所有文件的下载。这个过程现在需要几个小时。
服务器URL:ftp://ftp.ncep.noaa.gov/pub/data/nccf/com/gfs/prod/gfs.20210212/00/
文件:gfs.t00z.pgrb2.0p25.f${i}(必须完整下载)
我的wget请求在for循环里面比较简单,如下:
for i in {006..240..6}
do
wget -O /path/to/file/${ymd}/gfs.t${run}z.pgrb2.0p25.f$i ftp://ftp.ncep.noaa.gov/pub/data/nccf/com/gfs/prod/gfs.${ymd}/${run}/gfs.t${run}z.pgrb2.0p25.f$i
# Other Commands After wget Request Completed Here
done
我也曾尝试使用 aria2c 程序代替 wget,但发现完成时间差别不大。我曾讨论过将所有这些文件包装在一个文本文件中并将此列表传递给 wget,每 15 秒暂停一次下载等。
有没有有效的方法解决这个问题?
谢谢!
一个选项是同时下载多个文件?我没有在你的服务器上测试它,但假设你同时下载 5 个文件,它的速度大约是原来的 5 倍(假设你没有达到你或他们的最大互联网速度)。
实现可能如下所示:
for i in {006..240..6}; do
# Notice the & at the end of the next line. It's to start the wget process in a background thread. Our current thread just continues without waiting for wget
wget -O /path/to/file/${ymd}/gfs.t${run}z.pgrb2.0p25.f$i ftp://ftp.ncep.noaa.gov/pub/data/nccf/com/gfs/prod/gfs.${ymd}/${run}/gfs.t${run}z.pgrb2.0p25.f$i &
# Sleep until we have less than 5 running wget jobs at the same time
while [ $(jobs | wc -l) -ge 5 ]; do
sleep 1
done
done
for i in {006..240..6}; do
# We have all the files downloaded. Now do something with them.
echo Other Commands After wget Request Completed Here
done
我在 Ubuntu LTS 中使用 wget 程序每天从网络服务器下载一系列文件。最近,此 Web 服务器不堪重负,负责维护它的组织 (NCEP) 似乎已开始限制下载请求的数量和速度。
主要提示:在此之前,wget 能够在 15 分钟内完成所有文件的下载。这个过程现在需要几个小时。
服务器URL:ftp://ftp.ncep.noaa.gov/pub/data/nccf/com/gfs/prod/gfs.20210212/00/
文件:gfs.t00z.pgrb2.0p25.f${i}(必须完整下载)
我的wget请求在for循环里面比较简单,如下:
for i in {006..240..6}
do
wget -O /path/to/file/${ymd}/gfs.t${run}z.pgrb2.0p25.f$i ftp://ftp.ncep.noaa.gov/pub/data/nccf/com/gfs/prod/gfs.${ymd}/${run}/gfs.t${run}z.pgrb2.0p25.f$i
# Other Commands After wget Request Completed Here
done
我也曾尝试使用 aria2c 程序代替 wget,但发现完成时间差别不大。我曾讨论过将所有这些文件包装在一个文本文件中并将此列表传递给 wget,每 15 秒暂停一次下载等。
有没有有效的方法解决这个问题?
谢谢!
一个选项是同时下载多个文件?我没有在你的服务器上测试它,但假设你同时下载 5 个文件,它的速度大约是原来的 5 倍(假设你没有达到你或他们的最大互联网速度)。
实现可能如下所示:
for i in {006..240..6}; do
# Notice the & at the end of the next line. It's to start the wget process in a background thread. Our current thread just continues without waiting for wget
wget -O /path/to/file/${ymd}/gfs.t${run}z.pgrb2.0p25.f$i ftp://ftp.ncep.noaa.gov/pub/data/nccf/com/gfs/prod/gfs.${ymd}/${run}/gfs.t${run}z.pgrb2.0p25.f$i &
# Sleep until we have less than 5 running wget jobs at the same time
while [ $(jobs | wc -l) -ge 5 ]; do
sleep 1
done
done
for i in {006..240..6}; do
# We have all the files downloaded. Now do something with them.
echo Other Commands After wget Request Completed Here
done