Keeping a Java app running when SSH is closed on Google Cloud
You state this:
I would like this app (which is a server) to persist after I terminate SSH, and, at any point, I would like to be able to reconnect to the console and issue commands on the server.
Slightly vague in goals, but I will take a stab at it!
To run any command as a background process on a Linux server, you should prepend the command with nohup
and append &
to the end.
So the final command would be:
nohup [your command] &
The nohup
means the command should ignore “hang ups” and the ampersand &
appended to it is a shell command that tells the system to run the command as background process. More information on it’s usage can be found here.
When you run a command like this, the process will run, you will be sent back to the command prompt and you can exit the terminal session or even go and do something else unrelated to that command during that terminal session.
There are at least three ways to do this: nohup
('no hang up'), screen
/tmux
, or disown
. It's a little unclear from you question as to your need to connect to the server and interact with the daemon after you disconnect.
If this is the case, nohup
and disown
won't be good matches as you release the process (though it keeps running). tmux
(and also screen
) will keep a term running even when you.
For more info you can see the respective pages:
man nohup
man tux
Bash disown (assuming you are running Bash, though many other shell include something similar)