Anju
Anju

Reputation: 11

How to prevent Spring MVC application to shutdown after closing the terminal?

I have a Spring MVC application that runs with the normal SpringApplication.run(Application.class, args); statement. When I run it and then close the terminal window, it kills the process. How can I prevent it from shutting down when I close the terminal window?

I'm using OSX 10.9, Mavericks.

Thank you very much.

Upvotes: 0

Views: 1172

Answers (1)

Will Keeling
Will Keeling

Reputation: 23004

As Dave Syer says, you're best to use the nohup command which will prevent the child process from hanging up when the terminal window closes.

For example:

nohup java -jar name.jar 2>&1 >output.log &

That will send both the standard out and standard error to the output.log file. You can omit the >output.log and nohup will use the default log file called nohup.out.

Upvotes: 3

Related Questions