Passing a command to start a Java process?

I have a Java process that I am running. If I run the process through SSH and pass commands, it works fine, but if I end the SSH session, I will lose the “control” of the process. How can I restore the “control” of this process? He is still working.

I know the process id. Is this possible, or should I restart the process?

+3
source share
3 answers

You probably want to start the screen.

Try typing screenon the command line. (Install the program if you do not have one.)

Execution Example:

$ 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

the next day

$ ssh yourserver
Password:

$ screen -x                      # reattach process

$ java -jar YourApp.jar
output...
more output...                   # back to where we were yesterday.

Enter man screenfor more information.

+7
source

GNU screen.

+1

It is not possible to reconnect the standard input / output of a process that is so disconnected. This does not apply to Java applications.

To avoid getting into this situation, run the application using a utility screenor something similar.

0
source

Source: https://habr.com/ru/post/1750904/


All Articles