Reputation: 111
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:
--background
option for start-stop-daemon> /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)> /dev/null 2>&1 & </dev/null &
(source)&
to the end of the commandnohup
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?
Upvotes: 1
Views: 1401
Reputation: 101
sudo loginctl enable-linger your_user
# This allows users who are not logged in to run long-running
# service after ssh session ends
Upvotes: 2
Reputation: 111
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.
Upvotes: 0
Reputation: 21
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.
Upvotes: 2
Reputation: 21
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
Upvotes: 2