How to start, stop and restart rtorrent?
Solution 1
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
Solution 2
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
).
Related videos on Youtube
Alpaslan
Updated on September 18, 2022Comments
-
Alpaslan almost 2 years
Say, I have a string like the first line and I need to convert it to the second line.
"English ,Spanish ,Eastern Japanese " "English,Spanish,Eastern Japanese"
As you see, there are several whitespaces before commas, but each element may have spaces between its variables, too (like "Eastern Japanese"). So, all I need is to delete multiple whitespaces coming before commas. I can trim the last occuring whitespaces before using
replaceAll()
method, that is no problem.-
Admin almost 11 yearshave you tried
sudo service start rtorrent
? -
Admin almost 11 years
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. -
Admin almost 11 yearsYeah, 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.
-
Admin almost 11 yearsI'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 almost 11 yearsThis 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.
-
Alpaslan almost 9 yearsWorks like a charm. Much appreciated
-
Wiktor Stribiżew almost 9 yearsLike question, like answer :)
-
David Foerster almost 8 years
kill -s 15 `pidof rtorrent`
could be more simplykillall rtorrent
(15 orSIGTERM
is the default signal sent bykill
andkillall
). -
David Foerster almost 8 yearsAlso, 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. -
Cbhihe almost 8 yearsShould 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. -- Fromman 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. -
Zanna almost 7 yearsDon't forget about
pgrep
:) The commandpgrep rtorrent
returns just the PID, so no need for piping or parsing -
Skippy le Grand Gourou about 5 yearsIt's worth mentioning that it can take a while for
rtorrent
to close all files and exit afterCtrl
+q
— it doesn't mean it wasn't the right combination.