How do I keep a process, specifically one spawned via the sbt
command, alive after exiting my ssh
session? The following related questions [1], [2], [3] and [4] have been informative but have not led to a definitive solution in my particular case. A brief background: I have three servers representing nodes that comprise a cluster and each node has the the same program running on it to distribute computationally intensive tasks. This process is intended to always run while the machines are up, i.e. each server is dedicate solely to this project. Each node has the following (I will update this with the correct information when I get a chance to log back in):
Ubuntu 12.04.2 LTS
JVM X.X.X (is JDK 1.7 update 24+)
Scala X.X.X
sbt X.X.X
I access each node through my university's network via ssh
. I have tried tmux
and detaching a session, but this only persists the process as long as my own laptop does not restart. I take the following steps to begin the program on each node:
- Log into each node via
ssh user@host -p port
- Navigate to the appropriate directory and start my program with
sbt
* - Issue the
run
command in thesbt
console
* The actual command is sbt -Dgeotrellis cluster_seed_ip=xxx.xxx.xxx.xxx
Is disown
or nohup
the most appropriate approach to take? Given an answer for one or the other, what specific and syntactically correct command do I need to issue (from the sbt
console if using the disown
approach) so that the sbt
process disassociates from my user account and will continue running after I exit the ssh
session?
It looks like SBT hanging in the background is a JLine issue. There is a workaround:
Just add this flag to any SBT command you want to run in the background.
It is not a easy task to put sbt run as a daemon.
Most suggestions are using sbt-assembly.
If you donot want to using sbt-assembly, you may first package you scala application, then run it with scala command.
For me, the commands are, in this way, scala will continue to run after you exit ssh:
It is even more common. Try to type
sbt clean &
orsbt compile &
. Proccess is created but it won't finish.Solution for your question by using
tmxux
:In your context
SHELL_COMMAND
=sbt -Dgeotrellis cluster_seed_ip=xxx.xxx.xxx.xxx
You can also use
tmux
behindbyobu
:After that if you type
byobu
then you enter session of your command.