Karl Rixon

Archive for the ‘rtorrent’ tag

Start rTorrent Automatically at Boot on Debian/Ubuntu

with 2 comments

I tend to use ruTorrent as a front-end for rTorrent and so I like to have rTorrent start silently and automatically on boot. Most of the guides on this subject seem to suggest using an init script placed in /etc/init.d, but this is more complicated than it needs to be in my opinion. You can use start-stop-daemon instead which is much simpler and yields the same result. Here’s how.

First install dtach:

1
sudo apt-get install dtach

Then edit your /etc/rc.local file:

1
sudo nano /etc/rc.local

By default this file looks something like this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

exit 0

Add the following before exit 0, making sure to replace karl with the user as which you would like to run rTorrent, and /usr/local/bin/rtorrent with the location of rTorrent on your system (/usr/bin/rtorrent if you installed from the repo, /usr/local/bin/rtorrent if you compiled rTorrent from source with the default install path):

1
start-stop-daemon --start --chuid karl --name rtorrent --exec /usr/bin/dtach -- -n /tmp/rtorrent.dtach /usr/local/bin/rtorrent

Your /etc/rc.local should now look like this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

start-stop-daemon --start --chuid karl --name rtorrent --exec /usr/bin/dtach -- -n /tmp/rtorrent.dtach /usr/local/bin/rtorrent

exit 0

Press ctrl+o to save the file and ctrl+x to quit nano.

That’s it! To test you can either reboot, or else manually run the rc.local script:

1
sudo /etc/rc.local

If you don’t use an rTorrent front end, or want to view rTorrent in a terminal for whatever reason, you can reattach it to your terminal with the following command:

1
dtach -a /tmp/rtorrent.dtach

You can either press ctrl+z or simply close the terminal to quit dtach (rTorrent will keep running in the background).

Written by Karl

September 2nd, 2010 at 1:55 am

Posted in Linux

Tagged with ,