How can I get spring-boot to run forever on ubuntu?

若如初见. 提交于 2019-12-05 00:11:43


I'm trying to run spring-boot on a vm and have nginx proxy all request towards it. I've got this working but when I run:

mvn spring-boot:run

And my ssh session ends, it will stop the spring boot instance. (as expected)

I've also tried adding the <executable> config and sym-linking the spring-boot jar to a service, like so:


Then symlink the .jar:

sudo ln -s /var/users-java/target/user-0.0.1-SNAPSHOT.jar /etc/init.d/user_service

Now when I run the service:

sudo /etc/init.d/user_service start

It will log out:

Started [26208]

But not run the actual server?! The 26208 PID won't show up in my processes either!

Any ideas? Is there an alternate way of running a spring boot app forever? Like the forever tool in node?


If you are running you application in ubuntu, you can use nohup and & to run your process in background. It is simple and I hope it will solve your problem

nohup mvn spring-boot:run &


To run a command even after You logout you can use nohup command.

nohup stands for "no hangup." nohup is a POSIX command to ignore the hangup signal. The hangup signal is, by convention, the way a terminal warns dependent processes of logout.

Your command will look somewhat like

nohup mvn spring-boot:run &