1

EDIT this is fixed. See my answer below.


I have a headless server running transmission-daemon on Angstrom Linux. I am able to SSH into the machine and invoke transmission-daemon via this init script; however, the process terminates as soon as I log out.

The command issued in the script is:

start-stop-daemon --chuid transmission --start --pidfile /var/run/transmission-daemon.pid --make-pidfile --exec /usr/local/bin/transmission-daemon --background -- -f

After starting the daemon via # /etc/init.d/transmission-daemon start, I can verify using ps that the process is owned by the user transmission (which is not the user I am logging in as via SSH).

I've tried every variation of the above command that I am aware of, including:

  • With and without the --background option for start-stop-daemon
  • Appending > /dev/null 2>&1 & to the start-stop-daemon command (source -- although there seems to be mixed results in that thread as to whether this is the right approach)
  • Appending > /dev/null 2>&1 & </dev/null & (source)
  • Adding & to the end of the command
  • Using nohup

None of these seems to work -- the result is always the same: the process exits immediately after I close the SSH session.

What can/should I do to keep the daemon running after I disconnect the SSH session?

Community
  • 1
  • 1
Rick U
  • 111
  • 3

4 Answers4

2

Have you tried using GNU Screen?

It allows you to keep your session open even if you disconnect (but not if you exit).

It's a simple case of:

apt-get install screen

or

yum install screen
  • Thank you for your answer. To clarify, this init script was previously working correctly. I would really prefer to get the init script working again if possible. – Rick U Jul 09 '14 at 03:53
2

Since I cannot leave comments yet :), here is a good site that explains some functions of Screen, http://www.tecmint.com/screen-command-examples-to-manage-linux-terminals/

I use screens all the time, to do exactly what you are talking about. You open a screen, in the terminal, do what you need to do, then you can log off and your process will still be running.

user300217
  • 21
  • 1
2
sudo loginctl enable-linger your_user 
# This allows users who are not logged in to run long-running
# service after ssh session ends
0

This is now resolved. Here's the background: at some point prior to running into this problem, something happened to my $PATH (I don't recall what) and the location where transmission-daemon lived (/sbin) was removed. Under the mistaken impression that transmission-daemon was no longer present on the system, I installed again from an ipk. This is the state the system was in when I initially asked this question.

I don't know why it made a difference, but once I corrected my $PATH and started running transmission-daemon installed at /sbin, everything worked again. The daemon keeps running after I log out.

Rick U
  • 111
  • 3