Choose language

Portal Home > Knowledgebase > How-to > Seedboxes > rTorrent and ruTorrent > rtorrent and rutorrent - multiple instances

rtorrent and rutorrent - multiple instances

This article describes how to run multiple instances of rtorrent and rutorrent on our shared seedboxes. You can change rutorrent1 username to your username in the whole article, and in all commands which you want to have, for another rtorrent/rutorrent instance.

Please login to your seedbox SSH, here is an article how to do this:

1. Firstly create a new downloads path and other required directories for a new user:

mkdir -p ~/downloads/rutorrent1/watch ~/.config/.rutorrent1/.session

2. Copy rtorrent.rc file for a new user:
cp ~/.rtorrent.rc ~/.rutorrent1.rc

3. Now edit .rutorrent1.rc file:

Find these lines:

directory = ~/downloads
schedule = watch_directory,5,5,load_start=~/downloads/watch/rtorrent/*.torrent
session = /home/seedbox/.config/.session
scgi_port =
execute = {sh,-c,/usr/bin/php /yourhome/yourusername/www/ yourusername &}

Change them with sed using the following commands:
sed -i "s:^directory.*:directory = ~/downloads/rutorrent1:" ~/.rutorrent1.rc

sed -i "s:/downloads/watch/rtorrent:/downloads/rutorrent1/watch:" ~/.rutorrent1.rc

sed -i "s:.config/:.config/.rutorrent1/:" ~/.rutorrent1.rc

sed -i "s:scgi_.*:scgi_port = localhost\:$(shuf -i 13000-13500 -n 1):" ~/.rutorrent1.rc

sed -i "s:php $(whoami):php rutorrent1:" ~/.rutorrent1.rc

That's all with rutorrent1.rc file.

4. Now create a rutorrent1 directory under your www path
mkdir -p ~/www/$(whoami).$(hostname)/$(whoami)/rutorrent1/

5. Copy rutorrent files to rutorrent1 directory
cp -fr ~/www/$(whoami).$(hostname)/$(whoami)/rutorrent/* ~/www/$(whoami).$(hostname)/$(whoami)/rutorrent1/

6. Now remove all your main user settings like: traffic/torrents history, hdd usage etc. from rutorrent1 configuration:
rm -rf ~/www/$(whoami).$(hostname)/$(whoami)/rutorrent1/share/users/$(whoami)

7. If you have installed autodl-irssi plugin, you need to remove it as well:

rm -rf ~/www/$(whoami).$(hostname)/$(whoami)/rutorrent1/plugins/autodl*

8. You need to edit rutorrent1 config file:

sed -i "s:\$scgi_port.*:\$scgi_port = \"$(grep scgi .rutorrent1.rc | awk -F ':' '{print $2}')\";:" ~/www/$(whoami).$(hostname)/$(whoami)/rutorrent1/conf/config.php

sed -i "s:\$XMLRPCMountPoint.*:\$XMLRPCMountPoint = \"$(whoami)/rutorrent1/RPC1\";:" ~/www/$(whoami).$(hostname)/$(whoami)/rutorrent1/conf/config.php

sed -i "s:\$topDirectory.*:\$topDirectory = \'$HOME/downloads/rutorrent1\';:" ~/www/$(whoami).$(hostname)/$(whoami)/rutorrent1/conf/config.php

sed -i "s:rutorrent/error:rutorrent1/error:" ~/www/$(whoami).$(hostname)/$(whoami)/rutorrent1/conf/config.php

9. Configure user rutorrent1 authentication for RPC and rutorrent access.

echo -e "SCGIMount /$(whoami)/rutorrent1/RPC1$(grep scgi .rutorrent1.rc | awk -F ':' '{print $2}')\n\n" > ~/.apache2/conf.d/rutorrent1.conf

echo -e "<Location /$(whoami)/rutorrent1/RPC1>\nAuthName 'rutorrent1'\nAuthType Basic\nAuthBasicProvider file\nAuthUserFile '$HOME/.apache2/rutorrent1_auth'\nRequire valid-user\n</Location>" >> ~/.apache2/conf.d/rutorrent1.conf

echo -e "AuthName 'Private'\nAuthType Basic\nAuthBasicProvider file\nAuthUserFile '$HOME/.apache2/rutorrent1_auth'\nRequire valid-user" > ~/www/$(whoami).$(hostname)/$(whoami)/rutorrent1/.htaccess

htpasswd -cb ~/.apache2/rutorrent1'_auth' rutorrent1 password

For a password choose one which you want to have for rutorrent1 user.

10. Restart the apache webserver:
/usr/sbin/apache2ctl -k graceful

11. Start rtorrent in screen:
screen -dm -S rutorrent1 rtorrent -n -o import=~/.rutorrent1.rc

12. Create a cronjob to check every 5 minutes if rtorrent is running for rutorrent1 user, if not this will start it :
(crontab -l ;echo -e "*/5\t*\t*\t*\t*\tps x | grep rutorrent1 | grep -v grep || screen -dm -S rutorrent1 rtorrent -n -o import=~/.rutorrent1.rc && screen -wipe") | crontab -u $(whoami) -

That's all, now you should install the proftpd server from your manager and configure it for a new user so that he will have an access only to his downloads path. Here is an article on how to do this:


Ho to delete user rutorrent1 and all his files:

1. Firstly delete cronjob for user:

crontab -l | sed -e "/rutorrent1/d" | crontab -u $(whoami) -

2. Stop rtorrent of rutorrent1 user:
kill -9 $( pgrep -f rutorrent1)

3. Remove all user files:
rm -rf ~/www/$(whoami).$(hostname)/$(whoami)/rutorrent1

rm -f ~/.apache2/rutorrent1*

rm -f ~/.apache2/conf.d/rutorrent1*

rm -rf ~/downloads/rutorrent1

4. Restart the apache webserver:
/usr/sbin/apache2ctl -k graceful

Was this answer helpful?

Add to Favourites Add to Favourites    Print this Article Print this Article

Also Read