[英]Spring Boot Jar file start by terminal using nohup
Spring has this documentation for running an executable spring boot jar. Spring有此文档,用于运行可执行的Spring Boot jar。
However, I ran this jar from terminal using the nohup linux command, and worked fine. 但是,我使用nohup linux命令从终端运行了这个jar,并且运行良好。
The question is: Using nohup or using init.d service, will have the same result for the application? 问题是:使用nohup或使用init.d服务,对应用程序会有相同的结果吗? Or using the init.d is the correct way always? 还是使用init.d始终是正确的方法?
They do different things. 他们做不同的事情。 nohup
runs a command, and ignores the HANGUP (HUP) signal. nohup
运行命令,并忽略HANGUP(HUP)信号。 init.d
is for running a command automatically at server start-up (and shutting commands down orderly on shutdown). init.d
用于在服务器启动时自动运行命令(并在关闭时按顺序关闭命令)。 If you want your spring boot application to run automatically after the system restarts, put it in init.d
- if you want to manually start it after every reboot you can use nohup
. 如果要让Spring Boot应用程序在系统重启后自动运行,请将其放在init.d
-如果要在每次重启后手动启动它,则可以使用nohup
。
nohup
runs the command in a way that will be immune to hangups, which could cause problems. nohup
以不受挂断影响的方式运行命令,挂断可能导致问题。 A lot of programs are designed to re-read their configuration files, restart, or do other things when they receive HUP signals (most services/daemons restart or re-read configs). 许多程序旨在接收它们的HUP信号时重新读取其配置文件,重新启动或执行其他操作(大多数服务/守护程序重新启动或重新读取配置)。 Unless you specifically want to ignore HUP signals, using nohup
isn't the best solution. 除非您特别想忽略HUP信号,否则使用nohup
并非最佳解决方案。
You can use &
after the command in order to run it in the background, and if you want to avoid output to the terminal, you can send the output to /dev/null: 您可以在命令后使用&
以便在后台运行它,并且如果要避免输出到终端,可以将输出发送到/ dev / null:
mycommand > /dev/null 2>&1 &
The 2>&1
will send stderr to stdout, so it goes to /dev/null. 2>&1
会将stderr发送到stdout,因此转到/ dev / null。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.