21

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

How do I start | stop | restart the service?

  • have you tried sudo service start rtorrent? – BiggJJ Jun 28 '13 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 '13 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 '13 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 '13 at 23:57
22

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

  • 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 '13 at 11:49
  • 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. – Skippy le Grand Gourou May 13 at 8:38
3

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)(1) 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(2) 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).

  • 1
    kill -s 15 `pidof rtorrent` could be more simply killall rtorrent (15 or SIGTERM is the default signal sent by kill and killall). – David Foerster Jul 25 '16 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. – David Foerster Jul 25 '16 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 '16 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 '17 at 7:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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