Bernad Ali Bernad Ali - 5 months ago 65x
Bash Question

Run java jar file on a server as background process

I need to run a java jar in server in order to communicate between two application,i have written to shell script to run it ,but once i startup that script i can't shutdown / terminate the process,if i press ctrl+C or close the console ,server will shutdown. any one could help me how do i modify this script to run as normal server ?

java -jar /web/server.jar
echo $!


You can try this:

nohup java -jar /web/server.jar &

The & symbol, switches the program to run in the background.

The nohup utility makes the command passed as an argument run in the background even after you log out.