25

I just installed rtorrent on my Ubuntu Server 12.04 machine via apt-get.

How do I start | stop | restart the service?

4
  • have you tried sudo service start rtorrent?
    – BiggJJ
    Jun 28, 2013 at 23:24
  • sudo service rtorrent start that is, but yes, I've tried that. It just outputs rtorrent: unrecognized service. If I write sudo service rto and press tab it completes to rtorrentInit.sh. I don't know what that is, but I remember (from a guide that is long gone far off into the interwebs) that I wrote rtorrent and stop, but not in which order and whether there is another word in between. I did not write rtorrentInit.sh that first time.
    – lindhe
    Jun 28, 2013 at 23:31
  • Yeah, Thats what I meant. Have a look here: Ubuntu 12.04 LTS Dedicated Server rTorrent. The last 7-8 steps are about installing and starting rtorrent. Maybe it can shed some light.
    – BiggJJ
    Jun 28, 2013 at 23:40
  • I've already read that from top to bottom. But thank you anyways. For the moment I can get around with screen and just jump into rtorrent and quit from in there, but I'll leave this thread open if anyone happens to know the answer.
    – lindhe
    Jun 28, 2013 at 23:57

2 Answers 2

25

To start rtorrent, just press Ctrl+Alt+T on your keyboard to open Terminal. When it opens, run the command(s) below:

rtorrent

To stop Ctrl+D To quit Ctrl+q

The above commands you do after pressing Enter, in the rtorrent window.

For more information see the output of:

rtorrent -h

and/or see Using rtorrent like a pro

2
  • This is the correct answer. I am afraid that I might have mixed up the instructions for this program with some other program, so exactly what I was looking for probably does not exist. I apologize for the trouble, but hope someone else will have use of this thread.
    – lindhe
    Jun 29, 2013 at 11:49
  • 2
    It's worth mentioning that it can take a while for rtorrent to close all files and exit after Ctrl+q — it doesn't mean it wasn't the right combination. May 13, 2019 at 8:38
5

The accepted answer is correct but does not specify how to perform a "safe" shutdown of the rtorrent service with a systemctl service script.

Most existing answers or scripts "kill" either the screen session or the rtorrent process itself. In doing so, they send a SIGINT (2)or SIGQUIT (3) signal which stops/kills the rtorrent process. The drawback is that typically the lock-file of rtorrent is not deleted because rtorrent was not shut down properly. Consequently, the next start of rtorrent would fail because of the persistent lock file.

Taking a look at the source code of rtorrent shows that it expects a SIGTERM (15). Hence, considering a systemctl service script the stop command could look like:

ExecStop=/usr/bin/kill -s 15 \`pidof rtorrent`

If pidof is not available you can also use something like:

ps -A | grep "rtorrent" | awk '{print $1}'
  • ps list the current processes
  • grep extracts the rtorrent process particulars
  • awk selects the pid and displays it to stdout

In case you need to wait until shutdown is complete, you can use killall -w. Note that:

killall may wait forever if the signal was ignored, had no effect, or if the process stays in zombie state (source: man killall).

4
  • 1
    kill -s 15 `pidof rtorrent` could be more simply killall rtorrent (15 or SIGTERM is the default signal sent by kill and killall). Jul 25, 2016 at 11:24
  • 1
    Also, where in signal_handler.cc do you see that rtorrent expects SIGTERM to terminate itself gracefully? I only see signal generic signal handler management code but no actual signal handlers. Jul 25, 2016 at 11:30
  • Should not that be: /usr/bin/kill -n 15 `pidof rtorrent` or /usr/bin/kill -s SIGTERM \$(pidof rtorrent) ? You're mixing up signal names and numbers. -- From man kill, kill -l will actually give you the list of signal names and corresponding signal codes. -- Also note that although back ticks, as in `cmd`, are not officially deprecated, I have read that $(cmd) is actually favored as clearer.
    – Cbhihe
    Jul 25, 2016 at 12:38
  • Don't forget about pgrep :) The command pgrep rtorrent returns just the PID, so no need for piping or parsing
    – Zanna
    Aug 20, 2017 at 7:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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