出口頻寬明明有 100M,可每次在 Linux 下用 wget 抓檔就是慢,關鍵在於 wget 不支援多執行緒。而在 Windows 下用迅雷下載完再傳進 Linux,來回折騰也麻煩。命令列有沒有能多執行緒的替代方案?有,就是 lftp。
[root@AS5 ~]# lftp -c "pget -n 10 https://downloads.sourceforge.net/kvm/kvm-17.tar.gz"
其中 pget -n 10 指定開 10 條連線,-c 則是續傳(continue),斷線了接著跑就好。
[root@AS5 ~]# lftp -v
會看到版本資訊,例如 LFTP Version 3.5.1,採 GNU General Public License 授權,使用的函式庫包含 Readline 5.1。
pget [OPTS] rfile [-o lfile]
Gets the specified file using several connections. This can speed up transfer, but loads the net and server heavily impacting other users. Use only if you really have to transfer the file ASAP.
Options:
-c continue transfer. Requires lfile.lftp-pget-status file.
-n maxconn set maximum number of connections (default is taken from pget:default-n setting)
手冊提醒得很清楚:多連線會加重網路與伺服器負擔,只在真的急著要檔案時才用。除此之外,lftp 還能做鏡像同步、位元組範圍下載等事,多翻 man 手冊收穫會很可觀。