Rick U
Rick U

Reputation: 111

How can I prevent a daemon started over SSH from terminating at logout?

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:

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

Answers (4)

Max Tkachenko
Max Tkachenko

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

Rick U
Rick U

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

user300217
user300217

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

WombatCombat
WombatCombat

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

Related Questions