I am experimenting with running Spring Boot apps on a remote CentOS 7 web server which has been successfully serving up apps on Apache and a stand-alone tomcat instance since day one. However, when I ssh to the remote server and launch a Spring Boot app (which is in a jar that contains its own embedded tomcat instance), the Spring Boot web service jar runs successfully while my ssh connection is live, but then terminates after my ssh session ends. What specific steps do I have to take to get the jar containing the Spring Boot web service to continue running after my ssh session is terminated?

Here is what I typed to start the app using an ssh session from my devbox many hundreds of miles away:

[ ~]$ cd /path/to/webservice
[ webservice]$ kill $(lsof -t -i:9000)
kill: usage: kill [-s sigspec | -n signum | -sigspec] pid | jobspec ... or kill -l [sigspec]
[ webservice]$ java -jar mywebservice.jar

Since apache forwards requests for the service internally to port 9000, the service is then exposed to the outside world via an apache url somedomain.com/someurlpattern until I terminate the ssh session.


1 Answer 1


Running a process in background and closing ssh session

There are many ways to do so:

1.The nohup command

You can use the nohup command to execute commands after you exit from a shell prompt.


  $ nohup java -jar mywebservice.jar > /path/to/webservice/logs/mylogfile.txt &

  ## exit from shell or close the terminal ##
  $ exit

2.The disown bash command

Another option is to use the disown command as follows:


  $ java -jar mywebservice.jar > /path/to/webservice/logs/mylogfile.txt &
  [1] 10685
  $ disown 10685
 $ ps
    PID TTY          TIME CMD
    10685 pts/0    00:00:00 wget
    10687 pts/0    00:00:00 bash
    10708 pts/0    00:00:00 ps
 $ logout

3.The screen command

You can also use the screen command for this purpose.

  • Answer updated , that should work
    – Ijaz Ahmad
    Commented Dec 30, 2015 at 20:41
  • Thank you and +1 for taking the time to look into this. I closed the terminal window containing the ssh session. I also used who and pkill ... to terminate ssh sessions. I then tested to see the web service is still working. But I want to wait a little while to confirm that the service is not running simply due to a session that has not timed out yet. I am somewhere on SE most days, so I will make a note to check in an answer this later. You can ping me to reach me if you need to. Thank you again.
    – CodeMed
    Commented Dec 30, 2015 at 21:06
  • 1
    The service was still working today, so I am marking this as accepted. Thank you again for helping solve this problem.
    – CodeMed
    Commented Jan 1, 2016 at 1:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .