Pass command to running java process?
I have a Java process that I run. If I start the process via SSH and pass commands to it works fine, but if I then terminate the SSH session I lose "control" of the process. How can I regain "control" of that process? It's still running.
I know the开发者_JAVA百科 process ID. Is this possible or must I restart the process?
You probably want to start a screen.
Try typing screen
at the prompt. (Install the program if you don't have it.)
Example run:
$ ssh yourserver
Password:
$ screen # start the screen
$ java -jar YourApp.jar
output...
more output...
<Ctrl-A D> # detach process for later reattach
$ exit # exit your ssh session
next day
$ ssh yourserver
Password:
$ screen -x # reattach process
$ java -jar YourApp.jar
output...
more output... # back to where we were yesterday.
Type man screen
for more information.
Use GNU screen
program.
There is no way to reconnect the standard input / output of a process that has become disconnected like that. This is not specific to Java apps.
To avoid getting into this situation, run your application using the screen
utility or something similar.
精彩评论