简体   繁体   English

使用nohup通过终端启动Spring Boot Jar文件

[英]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.

相关问题 如何使用Windows批处理文件一个一启动Spring Boot jar文件? - How to start spring boot jar files one by one using windows batch file? 如何使用 Linux 上的外部 *.ampl 启动可执行 spring 启动 jar 文件? - How to start executable spring boot jar file with external *.ampl on Linux? 相对于jar目录的Spring Boot日志文件未启动目录 - Spring Boot log file relative to jar directory not start directory 在运行spring boot jar时使用外部jar作为依赖文件 - Using external jar as dependency file while running spring boot jar 带有.jar文件和Spring Boot的Confiusion - Confiusion with .jar file and spring boot 从 Spring 启动应用程序启动 jar 应用程序 - Start jar app from Spring Boot application 如何使用 gradle 从 spring 引导应用程序生成 jar 文件? - How to generate jar file from spring boot application using gradle? 如何使用jenkins将spring boot jar文件部署到EC2? - How to deploy spring boot jar file to EC2 using jenkins? 文件打开终端并在OSX中启动.jar? - File to open terminal and start .jar in OSX? 使用 Spring Boot Maven 插件时,jar 文件中缺少 Spring Boot 应用程序中的资源 - resources in a Spring Boot application are missing from jar file when using Spring Boot Maven Plugin
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM