I have been unable to get tmux & rtorrent running with a systemd service file. My rtorrent.service:

After=network.target local-fs.target

ExecStart=/usr/bin/tmux -S /tmp/rtorrent.sock new-session -d -s rtorrent \'rtorrent -n -O import=/etc/rtorrent.rc\'
ExecStop=/usr/bin/tmux -S /tmp/rtorrent.sock send-keys -t rtorrent C-q


(Using Type=oneshot with RemainAfterExit=yes did not work, and I'm not convinced that is a solution anyway. I think running tmux this way ought to be done with Type=forking. Please correct me if I'm wrong!)

The output from systemctl status rtorrent:

● rtorrent.service - rTorrent
   Loaded: loaded (/etc/systemd/system/rtorrent.service; disabled)
   Active: failed (Result: exit-code) since Mon 2015-04-27 10:48:37 AEST; 22s ago
     Docs: https://github.com/rakshasa/rtorrent
  Process: 4433 ExecStart=/usr/bin/tmux -S /tmp/rtorrent.sock new-session -d -s rtorrent 'rtorrent -n -O import=/etc/rtorrent/rtorrent.rc' (code=exited, status=1/FAILURE)

Apr 27 10:48:37 vagrant tmux[4433]: usage: new-session [-AdDP] [-c start-directory] [-F format] [-n window-name] [-s session-name] [-t target-session] [-x width] [-y height] [command]
Apr 27 10:48:37 vagrant systemd[1]: rtorrent.service: control process exited, code=exited status=1
Apr 27 10:48:37 vagrant systemd[1]: Failed to start rTorrent.
Apr 27 10:48:37 vagrant systemd[1]: Unit rtorrent.service entered failed state.

Switching to the rtorrent user with su allows me to try the ExecStart command manually - which works fine. I'm at a loss to debug this further.

Thoughts? Thanks!

  • 1
    Why are you starting it in tmux?
    – jordanm
    Apr 27, 2015 at 1:36
  • You probably shouldn't be escaping the quotes - you are trying to pass that as a single argument to tmux, so just use quotes as you normally would.
    – muru
    Apr 27, 2015 at 1:55
  • 1
    @jordanm not really sure how that is relevant
    – mafrosis
    Apr 27, 2015 at 2:10
  • @muru that fixed it - at one point I was getting errors which I thought I fixed with the escaping.. oh well. Add an answer to claim your points
    – mafrosis
    Apr 27, 2015 at 2:11

1 Answer 1


systemd does its own interpretation of values of Exec and other keys. Therefore, you shouldn't write as if this is going to be passed to sh -c or something like that. In particular, if you want to treat a set of words as a single argument, quote it as you normally would, and don't escape the quotes. Consider this example from the systemd docs:


ExecStart=/bin/echo one ; /bin/echo "two two"

This will execute /bin/echo two times, each time with one argument: one and two two, respectively. Because two commands are specified, Type=oneshot must be used.

So the ExecStart line should be:

ExecStart=/usr/bin/tmux -S /tmp/rtorrent.sock new-session -d -s rtorrent 'rtorrent -n -O import=/etc/rtorrent.rc'

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.