I just installed rtorrent
on my Ubuntu Server 12.04 machine via apt-get
.
How do I start | stop | restart the service?
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It only takes a minute to sign up.
Sign up to join this communityTo 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
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
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 processesgrep
extracts the rtorrent process particularsawk
selects the pid and displays it to stdoutIn 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
).
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
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
/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.
pgrep
:) The command pgrep rtorrent
returns just the PID, so no need for piping or parsing
sudo service start rtorrent
?sudo service rtorrent start
that is, but yes, I've tried that. It just outputsrtorrent: unrecognized service
. If I writesudo service rto
and press tab it completes tortorrentInit.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 wrotertorrent
andstop
, but not in which order and whether there is another word in between. I did not writertorrentInit.sh
that first time.