Google
 

2007-01-28

aria2

aria2是Linux平台下的一个命令行下载工具。其命令名称为aria2c
sf.net简介:
Yet another utility for downloading files. It has segmented downloading engine in its core, and downloads one file from multiple URLs much faster than ordinary web browsers. aria2 currently supports HTTP, FTP and BitTorrent.

使用说明


此工具支持将一个文件分成多个区块进行下载,支持常用的http、ftp协议,也支持P2P下载,具备断点续传功能。

安装


./configure
make
[make check]
make install

简单使用示例


  • 将一个文件分成若干个区块进行下载:

  •  aria2c -s 5 http://ftp.linux.cz/pub/localization/OpenOffice.org/devel/build/Sources/OOo_SRC680_m201_source.tar.gz
    aria2c -s 5 --ftp-user=anonymous --ftp-passwd=anonymous ftp://ftp.linux.cz/pub/localization/OpenOffice.org/devel/build/Sources/OOo_SRC680_m201_source.tar.gz

    其中,-s参数为分割当前下载文件为多少个区块,后面的5就是块数,注意一个文件最多可分割为5个区块;--ftp- user参数用于设置ftp下载的用户名,--ftp-passwd参数当然就是用于设置ftp下载的用户密码了。
  • 有时可能所需要下载的文件非常大,不能在很短的时间内下载完成,又不想让下载进程单独占用一个ssh连接(指从非本机登录的情况),我一开始采用的办法是让aria2作为一个后台进程进行下载。示例如下:

  •  aria2c -s 5 http://ftp.linux.cz/pub/localization/OpenOffice.org/devel/build/Sources/OOo_SRC680_m201_source.tar.gz &

    参照命令行参考,也可以将aria2作为一个守护进程(daemon)来进行下载(效果基本上是一样的)。示例如下:
     aria2c -s 5 -D http://ftp.linux.cz/pub/localization/OpenOffice.org/devel/build/Sources/OOo_SRC680_m201_source.tar.gz

    特别提示


    在下载的过程中会出现无法正常完成的情况,此时也不必担心,aria2会将下载日志写入本地目录的.aria2文件中,如果要重启相应的下载,只需将没有完成的下载命令再执行一次即可,下载将从刚才断开的位置继续进行下载。

    最后还有一个小问题,如果采用后台守护进程进行下载,怎么才能知道是否已经下载完成了呢?其实方法也比较简单,首先是看本地下载目录中是否存在相应的.aria2文件,如果存在,肯定是出现了网络连接问题,需要重启刚才的下载,进行断点续传;如果本地下载目录中不存在相应的.aria2文件,也不表示已经正常下载完成了;如果只启动了一个aria2进程下载这个文件,没有其他aria2进程在下载东西的话,可以直接看当前系统进程中是否还存在那个aria2进程,示例如下:
     ps xf | grep aria2c

    如果查询后发现那个aria2进程已经正常退出了,则可以确定文件下载已经成功完成;最后,如果还不确信是否已经成功下载,可以查看下载到本地的文件修改时间是否已经不再持续更新了,当然,如果提供该文件下载的网站也同时提供MD5或其他校验码,对下载后的文件进行一下校验即可。

    命令行参考



    # aria2c --help
    Usage: aria2c [options] URL ...
    aria2c [options] -T TORRENT_FILE FILE ...

    Options:
    -d, --dir=DIR The directory to store downloaded file.
    -o, --out=FILE The file name for downloaded file.
    -l, --log=LOG The file path to store log. If '-' is specified,
    log is written to stdout.
    -D, --daemon Run as daemon.
    -s, --split=N Download a file using N connections. N must be
    between 1 and 5. This option affects all URLs.
    Thus, aria2 connects to each URL with
    N connections.
    --retry-wait=SEC Set amount of time in second between requests
    for errors. Specify a value between 0 and 60.
    Default: 5
    -t, --timeout=SEC Set timeout in second. Default: 60
    -m, --max-tries=N Set number of tries. 0 means unlimited.
    Default: 5
    --http-proxy=HOST:PORT Use HTTP proxy server. This affects to all
    URLs.
    --http-user=USER Set HTTP user. This affects to all URLs.
    --http-passwd=PASSWD Set HTTP password. This affects to all URLs.
    --http-proxy-user=USER Set HTTP proxy user. This affects to all URLs
    --http-proxy-passwd=PASSWD Set HTTP proxy password. This affects to all URLs.
    --http-proxy-method=METHOD Set the method to use in proxy request.
    METHOD is either 'get' or 'tunnel'.
    Default: tunnel
    --http-auth-scheme=SCHEME Set HTTP authentication scheme. Currently, basic
    is the only supported scheme.
    Default: basic
    --referer=REFERER Set Referer. This affects to all URLs.
    --ftp-user=USER Set FTP user. This affects to all URLs.
    Default: anonymous
    --ftp-passwd=PASSWD Set FTP password. This affects to all URLs.
    Default: ARIA2USER@
    --ftp-type=TYPE Set FTP transfer type. TYPE is either 'binary'
    or 'ascii'.
    Default: binary
    -p, --ftp-pasv Use passive mode in FTP.
    --ftp-via-http-proxy=METHOD Use HTTP proxy in FTP. METHOD is either 'get' or
    'tunnel'.
    Default: tunnel
    --lowest-speed-limit=SPEED Close connection if download speed is lower than
    or equal to this value(bytes per sec).
    0 means aria2 does not care lowest speed limit.
    You can append K or M(1K = 1024, 1M = 1024K).
    This option does not affect BitTorrent download.
    Default: 0
    --max-download-limit=SPEED Set max download speed in bytes per sec.
    0 means unrestricted.
    You can append K or M(1K = 1024, 1M = 1024K).
    Default: 0
    -T, --torrent-file=TORRENT_FILE The file path to .torrent file.
    --follow-torrent=true|false Setting this option to false prevents aria2 to
    enter BitTorrent mode even if the filename of
    downloaded file ends with .torrent.
    Default: true
    -S, --show-files Print file listing of .torrent file and exit.
    --direct-file-mapping=true|false Directly read from and write to each file
    mentioned in .torrent file.
    Default: true
    --listen-port=PORT Set port number to listen to for peer connection.
    --max-upload-limit=SPEED Set max upload speed in bytes per sec.
    0 means unrestricted.
    You can append K or M(1K = 1024, 1M = 1024K).
    Default: 0
    --select-file=INDEX... Set file to download by specifing its index.
    You can know file index through --show-files
    option. Multiple indexes can be specified by using
    ',' like "3,6".
    You can also use '-' to specify rangelike "1-5".
    ',' and '-' can be used together.
    --seed-time=MINUTES Specify seeding time in minutes. See also
    --seed-ratio option.
    --seed-ratio=RATIO Specify share ratio. Seed completed torrents until
    share ratio reaches RATIO. 1.0 is encouraged.
    If --seed-time option is specified along with
    this option, seeding ends when at least one of
    the conditions is satisfied.
    -v, --version Print the version number and exit.
    -h, --help Print this message and exit.

    URL:
    You can specify multiple URLs. All URLs must point to the same file
    or downloading fails.

    FILE:
    Specify files in multi-file torrent to download. Use conjunction with
    -T option. This arguments are ignored if you specify --select-file option.

    Examples:
    Download a file by 1 connection:
    aria2c http://AAA.BBB.CCC/file.zip
    Download a file by 2 connections:
    aria2c -s 2 http://AAA.BBB.CCC/file.zip
    Download a file by 2 connections, each connects to a different server:
    aria2c http://AAA.BBB.CCC/file.zip http://DDD.EEE.FFF/GGG/file.zip
    You can mix up different protocols:
    aria2c http://AAA.BBB.CCC/file.zip ftp://DDD.EEE.FFF/GGG/file.zip

    Download a torrent:
    aria2c -o test.torrent http://AAA.BBB.CCC/file.torrent
    Download a torrent using local .torrent file:
    aria2c -T test.torrent
    Download only selected files:
    aria2c -T test.torrent dir/file1.zip dir/file2.zip
    Print file listing of .torrent file:
    aria2c -T test.torrent -S

    Report bugs to <tujikawa at users dot sourceforge dot net>

    相关链接




    仅奉献此文以纪念这特别的一天

    标签:

    1 条评论:

    时间 2007年1月29日 星期一 下午11时56分00秒 CST , Blogger Chen Bo 说...

    你最后给出的链接,在中国大陆一般访问不了wiki,建议干脆发个帖子详细讲讲如何可以看到。呵

     

    发表评论

    << 主页