When downloading big files it necessary to pause the download many times. A big file can be downloaded by using wget
. First start download, then kill wget
, then resume download by wget -c
.
I want to pause downloads too many times depending on events such as power failure, Network unavailability, etc… and want to automate it using a script. So pressing Ctrl+C is't an option. I know a process can be paused by kill -STOP "$pid"
The pausing should not close the connection to the website, either it should wait for resume command or the bandwidth throttled to very low use.
I found these commands using aria2c
in aria2.sourceforge.net, but I can't use it successfully. This uses RPC method. Can I use it in a script?
aria2.pause(gid)
This method pauses the download denoted by gid. gid is of type string. The status of paused download becomes paused. If the download is active, the download is placed on the first position of waiting queue. As long as the status is paused, the download is not started. To change status to waiting, use aria2.unpause() method. This method returns GID of paused download.
aria2.unpause(gid)
This method changes the status of the download denoted by gid from paused to waiting. This makes the download eligible to restart. gid is of type string. This method returns GID of unpaused download.
Question
- How to pause (or throttle bandwidth) an already running download of aria
- Is there a better down loader than
aria
to use in script - Wether RPC method can be used in script
Best Answer
For this to work your
aria2
should support option pause. Search for--pause[=true|false]
inman aria2c
. It works in aria2_1.12.0-1_i386 [oneric] (and later).First start RPC server:
aria2c --enable-rpc=true
(For older ver.aria2c --enable-xml-rpc=true
)Then use RPC using
http://localhost:6800/jsonrpc
The following example adds http://example.org/file to aria2: In a python console type the following
JSON RPC
The following example pause download whose GID is "3":
XML RPC
If you get somethin like below your version of aria2 doesn't support it.
In version that use
aria2c --enable-xml-rpc=true
, other options can be used such as adiing files, etc. (using XML RPC).