This is a read-only archive. Find the latest Linux articles, documentation, and answers at the new Linux.com!

Linux.com

Feature: Filesharing & P2P

Headless torrent downloads with rTorrent and Screen

By Chad Files on June 12, 2008 (9:00:00 AM)

Share    Print    Comments   

I have a constantly running server that would be a perfect on which to run torrent downloads. The only catch is that the server is headless -- it has no monitor or keyboard. To overcome this obstacle, I use rTorrent as my torrent client, and GNU Screen so that I can disconnect my terminal session and leave rTorrent running.

rTorrent is a full-featured BitTorrent client that was built to run on a terminal. It uses ncurses as an interface layer and libTorrent under the hood. rTorrent is in the package repositories for most major distributions. If it is not available on your system you can download and install from source.

rTorrent has loads of settings and switches. All of the primary settings can be configured in the .rtorrent.rc file in your home directory; rTorrent looks for it every time it starts. A good place to start learning about the settings is with the example configuration on the project's Web site. Copy and paste the contents into ~/.rtorrent.rc

I recommend you change a few settings before you use rTorrent:

  • directory is a path where rTorrent will save downloaded files.
  • schedule -- This setting can be used several times in the configuration file to tell rTorrent what to do when certain events occur. It provides the ability to scan for new torrent files and remove torrents that have been deleted. For instance:
    schedule = watch_directory,5,5,load_start=~/*.torrent schedule = untied_directory,5,5,stop_untied=
    The first line scans for .torrent files in your home directory; if one is found, rTorrent will immediately queue the torrent when it is launched. The second line stops any torrent download if its source file is deleted.
  • max_uploads -- It is good practice to give a bit for every bit you receive, but too many connections can choke your network link. This setting allows you to limit how many leechers can connect to you at one time. I leave mine at 2 during the day when I am using my connection and up it to 5 at night.
  • upload_rate allows you to throttle your upload rate to a reasonable amount; 25 to 40 is a good range.
  • download_rate -- Downloading at full force can also choke your connection. This setting allows you to scale rTorrent's download speed. During peak usage I usually set this to 50.

If you do not want to bother with the configuration file, you can pass rTorrent all of these parameters; for more information consult the rTorrent man page.

Once you're set up, open a terminal and run rtorrent. The main screen shows you a summary of all the torrents that are currently queued. It has seven views that you can access by typing 1-7. The views sort and filter the active torrents by name and all the possible states (complete, incomplete, started, stopped, and so forth). From any of these screens you can navigate through the torrents by using the up and down arrow keys. Press Ctrl-s to start a download and Ctrl-d to stop one. If you type Ctrl-d twice, the torrent file, not the downloaded files, will be deleted.

rTorrent also provides extensive information about each download. To view the information, navigate to one of the torrents and press the right arrow key to launch the download view. From this view you can see a complete peer list, file information, tracker list, transfer list, and even the downloaded file chunks. To get back to the main view, press the left arrow key.

To exit rTorrent, type Ctrl-q. When rTorrent exits, it maintains the state of all the torrents. If there is a previously active torrent queued, then when rTorrent launches again it will do a complete hash check of the downloaded content and restore the torrent's state.

rTorrent has many more options and settings. For a complete list of everything available in rTorrent see the man page.

rTorrent with screen

rTorrent really shines when used in conjunction with Screen, which is essentially an interactive shell that attaches itself to a virtual terminal. It allows you to disconnect from a terminal session and leave everything in that session running. Screen is available in the package management system for most major distributions; you can also install it from source.

To start a Screen session, open a terminal and type screen. You will not notice much when Screen is launched; the screen will clear and you will be presented with a prompt. From here you can start any process, such as rTorrent, or run any command available on your system.

To detach the session, type Ctrl-A then Ctrl-D. Ctrl-A tells Screen that the next keystrokes will be a command. Ctrl-D is the detach command. Once you are detached you can exit the session and whatever is running will continue to run -- barring a catastrophe.

When you want to reconnect, you need to get the name of the detached session by using the -ls parameter (screen -ls) to list all of the screen sessions that are running. To reattach to one of them, use the -r parameter and pass in the name:

screen -r 12345.pts-1.machine

If only one screen session is running you can use the -r parameter without the name of the session.

Of course Screen can do much more than what is mentioned here; refer to its man page for more information.

rTorrent and Screen may not be the most flashy BitTorrent setup, but it is one of the most useful and full-featured.

Chad Files, a software developer and writer, has been developing software applications for more than 10 years, and is a contributing developer to many open source projects.

Share    Print    Comments   

Comments

on Headless torrent downloads with rTorrent and Screen

Note: Comments are owned by the poster. We are not responsible for their content.

Headless torrent downloads with rTorrent and Screen

Posted by: Anonymous [ip: 131.116.254.199] on June 12, 2008 10:30 AM
Good article! I have used a similar setup but have now abandoned it for torrentflux-b4rt which gives me the same functionality and a web interface.

#

Headless torrent downloads with rTorrent and Screen

Posted by: Anonymous [ip: 192.168.218.101] on June 12, 2008 12:30 PM
Don't forget to use moblock and check out the init scripts on the rtorrent website:
http://libtorrent.rakshasa.no/wiki/RTorrentCommonTasks

#

Headless torrent downloads with rTorrent and Screen

Posted by: Anonymous [ip: 87.182.20.85] on June 12, 2008 12:35 PM
Headless doesn't mean you can't run ordinary GUI applications.
You just have to use VNC or similar techniques.
You can keep the server running; to see the progress, log in via VNC,
look at the app's (e.g. KTorrent's) window, and kill the vncviewer again.

#

Headless torrent downloads with rTorrent and Screen

Posted by: Anonymous [ip: 220.225.232.238] on June 12, 2008 12:56 PM
Nice article.

I use the similar setup on my desktop machine. I tried many torrent client and always come back to rtorrent for it's low memory usage and it's stability.

#

Headless torrent downloads with rTorrent and Screen

Posted by: Anonymous [ip: 62.94.42.151] on June 12, 2008 02:20 PM
Well, screen is a great tool since 15 or more years now. Since the time of 2.4 kbps modems.
I would like to see it among the best 10 Unix tools of all times.
Nice article though!

#

Headless torrent downloads with rTorrent and Screen

Posted by: Anonymous [ip: 24.124.29.26] on June 12, 2008 03:17 PM
I have been doing this for a few years now. I can access my torrents from anywhere that has a net connection and ssh. One thing I found is a program called screenie which is a front end for screen, it makes things a little easier. Lately I have been eyeing transmission because you can set it up with a web interface.

#

Headless torrent downloads with rTorrent and Screen

Posted by: Anonymous [ip: 199.4.155.10] on June 12, 2008 03:42 PM
You should also check out torrentflux for a web based torrent interface. I've been using this for years on my server at home so I can manage torrents from anywhere : http://www.torrentflux.com/

#

Headless torrent downloads with rTorrent and Screen

Posted by: Anonymous [ip: 75.145.180.221] on June 12, 2008 04:17 PM
I use torrentflux-b4rt for my headless downloading pleasure...

#

Headless torrent downloads with rTorrent and Screen

Posted by: Anonymous [ip: 90.184.107.48] on June 12, 2008 04:50 PM
For the people wanting a web interface for rTorrent, there are several alternatives out there: http://libtorrent.rakshasa.no/wiki/UtilsList
I myself prefer the wTorrent project.

#

BitTorrent!

Posted by: Anonymous [ip: 12.155.58.181] on June 12, 2008 07:16 PM
The default BitTorrent client has a console version too. It uses Python scripts. I like it more than rTorrent.

#

Headless torrent downloads with rTorrent and Screen

Posted by: Anonymous [ip: 134.121.227.168] on June 12, 2008 07:36 PM
I wrote some scripts to automate the entire setup for multiuser rtorrent/screen usage. It searches for users that have .rtorrent.rc in their homedir, then loads screen and executes rtorrent for them, and then detaches... all on boot, so users can come and go as they please.

That was a pain, actually. So I switched to BTG... which is still a developing project, but I like it a lot so far.

#

Headless torrent downloads with rTorrent and Screen

Posted by: Anonymous [ip: 78.105.5.210] on June 12, 2008 08:57 PM
Nice article, this is best torrent setup.

#

Headless torrent downloads with rTorrent and Screen

Posted by: Anonymous [ip: 81.214.105.10] on June 13, 2008 09:10 AM
really great articel regards
http://www.yarn-paradise.com

#

Headless torrent downloads with rTorrent and Screen

Posted by: Anonymous [ip: 93.195.117.1] on June 13, 2008 02:26 PM
I used rtorrent with screen some years back, but dumped it after it turned out the developer would tweak it's bt algorithm implementation to it's advantage (and disadvantage of the swarm). Accordingly it got banned on a few sites back then.

If you want a good reputation and powerful console bt client for the Internet, get Azureus. It runs in console mode too. I've been running it inside screen for years now on my server, and you can even remotely connect either via HTTP or a remote Java client. It maybe has a larger memory footprint, but the 512MB RAM in that server are still ample even with other services running on it.

#

Headless torrent downloads with rTorrent and Screen

Posted by: Anonymous [ip: 212.187.121.152] on June 13, 2008 03:10 PM
I used to use bittornado with screen. Besides having textbase interface you can use the ncurses interface. It also has several options you can pass on the commandline like port, maxdownload/upload etc..

http://www.bittornado.com

#

Headless torrent downloads with rTorrent and Screen

Posted by: Anonymous [ip: 24.84.196.212] on June 13, 2008 04:48 PM
great article. I've been planning something like this for myself. It's good to hear what has worked for you and all the others who posted solutions. Well, all except for the Azureus one, god hates software bloat.

#

Headless torrent downloads with rTorrent and Screen

Posted by: Anonymous [ip: 85.141.255.22] on June 13, 2008 06:11 PM
Just every Linux distro goes with btdownloadmany script, that downloads whatever .torrent files you put into dedicated folder. Why bother with rtorrent and screen?

#

Headless torrent downloads with rTorrent and Screen

Posted by: Anonymous [ip: 209.234.142.51] on June 13, 2008 06:38 PM
This is the same set up I'm using at home. It works flawlessly. Another nice feature is to set your share ratio in the .rtorrent.rc file. I usually set it to 2:1 so that I've shared two copies of the torrent by the the time I'm done downloading.

Another handy feature is to share the torrent watch directory via samba, that way, no matter which computer I'm using on my network, I can copy a torrent file to the headless machine.

#

Headless torrent downloads with rTorrent and Screen

Posted by: Anonymous [ip: 10.214.77.99] on June 13, 2008 07:34 PM
If you want to lighten your memory & processor utilization, you should stop by http://www.nslu2-linux.org HowTo Recipes. They've several HowTos on a few different Torrent clients with Screen and Dtach (http://dtach.sf.net).

http://www.nslu2-linux.org/wiki/HowTo/RtorrentLikeAPro
http://www.nslu2-linux.org/wiki/HowTo/KeepRemoteConsoleSessionRunning
http://www.nslu2-linux.org/wiki/HowTo/BitTorrent
http://www.nslu2-linux.org/wiki/OpenSlug/InstallCtorrent

For something simple as rTorrent which offers an XML-RPC API for activity management, dtach may be a better combination (strip'd, the dtach executable is <13K, strip'd & gzexe'd = 6.7K)

http://www.nslu2-linux.org/wiki/HowTo/InstallRtorrentOnDebain (rTorrent and Perl's XML-RPC)

Dtach is pure ANSI C and compiles on most *nix systems without issue (some AIX my have psuedo terminal issues, google for it).

I switched from Screen to dtach and haven't gone back. Only if I need multiple tab-like terminal through one console terminal will use Screen.

Hope this helps you for more than your Torrents.

Later, Mr. Markus (Mark S.)

#

Headless torrent downloads with rTorrent and Screen

Posted by: Anonymous [ip: 99.230.117.234] on June 13, 2008 09:51 PM
running this the same way on mythbuntu and rtgui for web front end
http://code.google.com/p/rtgui/

#

Headless torrent downloads with rTorrent and Screen

Posted by: Anonymous [ip: 82.152.27.154] on June 16, 2008 02:56 PM
I use Azerus(sp?) - easy to use web-client that I can check from home or work. Does the job for me just fine on my Debian Sarge server at home.

#

This story has been archived. Comments can no longer be posted.



 
Tableless layout Validate XHTML 1.0 Strict Validate CSS Powered by Xaraya