I use PuTTY to connect to my Linux (centos 8) server by SSH. then I run my java program on server by the command
java -cp /.../ app
everything is fine and the program runs continuously, but when I close my SSH session in PuTTY, my java program gets also killed. why it happens and how to prevent it?!
2
Answers
This is an expected behavior. If you want to keep running your java jar file even though you close the SSH putty session , create a shell script and try to run the java application through running the shell script.
A sample script is shown below, you can modify according to your need :
Sample Script Content :
Go to the location of the script :
nohup is a POSIX command to ignore the HUP (hangup) signal. The HUP signal is, by convention, the way a terminal warns dependent processes of logout.
Output that would normally go to the terminal goes to a file called nohup.out if it has not already been redirected.
In short, it stands for no hang up.