Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pass command to running java process?

Tags:

java

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 process ID. Is this possible or must I restart the process?

like image 408
sam Avatar asked Jun 03 '26 10:06

sam


1 Answers

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.

like image 193
aioobe Avatar answered Jun 05 '26 23:06

aioobe



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!