Run Java console app as a daemon (background)

后端 未结 4 864
生来不讨喜
生来不讨喜 2020-12-14 13:16

I\'ve developed a Java console application that when start, open a console window and remain in foreground, i want to start that application in background .

Now i la

4条回答
  •  渐次进展
    2020-12-14 13:31

    If you really just want it to run in the background, java -jar myapp.jar & will do the job. That way, it'll still die when the shell closes, but you can keep using your shell.

    If you really want it run as a daemon, nohup java -jar myapp.jar & will do the job. That way, it'll continue to live when the shell closes.

    If you want this to be reliable, you can prepare an init script or upstart job definition, or run it via Vixie cron(8) @reboot specifier to make it start at boot.

提交回复
热议问题