Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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

  1. How to pause (or throttle bandwidth) an already running download of aria
  2. Is there a better down loader than aria to use in script
  3. Wether RPC method can be used in script
share|improve this question
add comment

2 Answers 2

up vote 4 down vote accepted

For this to work your aria2 should support option pasue. Search for --pause[=true|false] in man 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

import urllib2, json
jsonreq = json.dumps({'jsonrpc':'2.0', 'id':'qwer',
    'method':'aria2.addUri',
    'params':[['http://example.org/file']]})
c = urllib2.urlopen('http://localhost:6800/jsonrpc', jsonreq)
c.read()
'{"id":"qwer","jsonrpc":"2.0","result":"2089b05ecca3d829"}'

The following example pause download whose GID is "3":

XML RPC

import xmlrpclib
s = xmlrpclib.ServerProxy('http://localhost:6800/rpc')
s.aria2.pause('3')

If you get somethin like below your version of aria2 doesn't support it.

xmlrpclib.Fault: <Fault 1: 'No such method: aria2.pause'

In version that use aria2c --enable-xml-rpc=true, other options can be used such as adiing files, etc. (using XML RPC).

share|improve this answer
    
Works on Ubuntu 12.10 but not on 10.04 (option pasue not available) –  totti Mar 27 '13 at 10:40
add comment

Simplest you can use Ctrl + C shortcut in terminal/konsole to pause the download. Internally it makes a temporary file in the same directory of extension .aria2, and when you try to redownload the file, it starts from the position it was made to pause. And don't use Ctrl + Z.

share|improve this answer
1  
True, but can't use in a script. (about Ctrl + C already mentioed in line 5 of the question) –  Prinz Mar 25 '13 at 10:51
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.