多线程下载工具有aria2和axel
32位CentOS执行下面命令:
wget -c http://pkgs.repoforge.org/axel/axel-2.4-1.el5.rf.i386.rpm
rpm -ivh axel-2.4-1.el5.rf.i386.rpm
64位CentOS执行下面命令:
wget -c http://pkgs.repoforge.org/axel/axel-2.4-1.el5.rf.x86_64.rpm
rpm -ivh axel-2.4-1.el5.rf.x86_64.rpm
Axel命令使用方法:
axel 参数 文件下载地址
可选参数:
-n 指定线程数
-o 指定另存为目录
-s 指定每秒的最大比特数
-q 静默模式
如从Diahosting下载lnmp安装包指定10个线程,存到/tmp/:axel -n 10 -o /tmp/ http://soft.vpser.net/lnmp/lnmp0.7-full.tar.gz
如果下载过程中下载中断可以再执行下载命令即可恢复上次的下载进度。
首先看下axel的用法介绍:
1.usr/local/axel/bin/axel
Usage: axel [options] url1 [url2] [url...] --max-speed=x -s x Specify maximum speed (bytes per second) --num-connections=x -n x Specify maximum number of connections --output=f -o f Specify local output file --search[=x] -S [x] Search for mirrors and download from x servers --header=x -H x Add header string --user-agent=x -U x Set user agent --no-proxy -N Just don't use any proxy server --quiet -q Leave stdout alone --verbose -v More status information --alternate -a Alternate progress indicator --help -h This information --version -V Version information
复制代码
可以看到axel需要至少一个URL地址作为参数来提供下载地址,比如最简单的一个下载mysql-server的例子:
1.usr/local/axel/bin/axel http://ftp.iij.ad.jp/pub/db/mysql/Downloads/MySQL-5.5/MySQL-5.5.16-1.linux2.6.x86_64.tar
复制代码
回车,axel便会开始下载
http://ftp.iij.ad.jp/pub/db/mysq ... linux2.6.x86_64.tar
这个文件.
看看其它参数的意思:
-s 限制下载最大速度 bytes/秒
-n 设置下载连接数,比如 -n 10 最大开启10个下载连接(这里是连接数,不是线程数)
-o 下载后,在本地的存储文件名称
-S 查找该文件的镜像服务器(关于如何查找,后面会谈到) 如果输入x的话,会从前x个镜像服务器去下载,排名按照下载速度从大到小取前top x个.
-H 增加头信息,自持多个header信息, 比如 -H header1 -H header2 ..等
-U 设置用户代理,比如系统默认的代理信息 -U Axel 2.4 (Linux)
-N 不使用任何http代理
-q 仅仅保留标准输出
-v 输出更多的状态信息
-a 输出交替的进度条
-h 打印这个帮助信息
-V 打印版本信息
关于命令行参数的解析,在text.c的main函数中(大概92行左右)中能看到.
方法1:
#!/bin/sh -e
# usage: ./axel-batch.sh the-download-url.list
cat $1 | xargs -l1 axel -n8 -a
方法2:
#!/bin/sh -e
# usage: ./axel-batch.sh the-download-url.list
cat $1 | while read LINE
do
if [ -n "$LINE" ]; then
axel -n8 -a `echo $LINE`
fi
done
使用方法介绍
假设已知多个来源,分别为url1,url2 等
axel [options] url1 [url2] [url...]
--max-speed=x
-s x
Specify maximum speed (bytes per second)最高速度x
--num-connections=x
-n x
Specify maximum number of connections连接数x
--output=f
-o f
Specify local output file下载为本地文件f
--search[=x]
-S [x]
Search for mirrors and download from x servers搜索镜像
--header=x
-H x
Add header string添加头文件字符串x
--user-agent=x
-U x
Set user agent
--no-proxy
-N
Just don't use any proxy server不使用代理服务器
--quiet
-q
Leave stdout alone
--verbose
-v
More status information更多状态信息
--alternate
-a
Alternate progress indicator
--help
-h
帮助
--version
-V
版本信息
Aria2是一个命令行下运行、多协议、多来源下载工具(HTTP/HTTPS、FTP、BitTorrent、Metalink),内建 XML-RPC 用户界面。 安装方法参考
[编辑] 特点
多链接下载。
轻量,平均4-9MB内存使用量,BitTorrent下载速度2.8MiB/s时CPU占用约6%。
全面的BitTorrent特性支持,包括 DHT, PEX, Encryption, Magnet URI, Web-Seeding,选择下载,本地资源探测。 Mtalink支持。包括File verification, HTTP/FTP/BitTorrent integration and Configuration for language, location, OS, 之类。
https://github.com/angelj-a/axel
http://blog.youkuaiyun.com/open_source_road/article/details/6918825
28个Unix/Linux的命令行神器