在 Debian 服务器上重启 Java 进程
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/45382673/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Restart Java Process on Debian Server
提问by newUser.java
I'm using a remote server and to clean up some amount of RAM I've restarted some (not system) services in use but I can't restart the java process because the 'service' command can't find it (isn't a service? it's a oracle-java8 installation through the official apt-get installer).
我正在使用远程服务器并清理一些 RAM 我已经重新启动了一些(不是系统)正在使用的服务,但我无法重新启动 java 进程,因为“服务”命令找不到它(不是) t 服务?这是通过官方 apt-get 安装程序进行的 oracle-java8 安装)。
Any suggestion?
有什么建议吗?
[I've readed the other questions but there is not a proper solution for my case, I don't want to execute strange scrips. sorry]
[我已经阅读了其他问题,但我的情况没有合适的解决方案,我不想执行奇怪的脚本。对不起]
采纳答案by newUser.java
Problem solved. I've verified that the java process is the execution of a jar, so just killing and re-launch it.
问题解决了。我已经验证了java进程是一个jar的执行,所以只需杀死并重新启动它。
The clue has been that in my local pc the jre don't have a daemon-like process.
线索是在我的本地电脑中,jre 没有类似守护进程的进程。
回答by Stijn Haezebrouck
apt-get install oracle-java8-jdk/jre
would not create java as a service. It would install the JDK/JRE so that you can run jar files as such:
apt-get install oracle-java8-jdk/jre
不会将 java 创建为服务。它将安装 JDK/JRE,以便您可以像这样运行 jar 文件:
# java -jar myjarfile.jar
The java process on your server might have been started this way in a console or tty.
您服务器上的 java 进程可能已在控制台或 tty 中以这种方式启动。
If you want to run this jar as a service, you need to create a wrapper script that supports start, stop, restart etc. (like explained here) Without a wrapper script, a java .jar program cannot be managed as a service on Linux.
如果你想运行这个jar作为一种服务,你需要创建一个包装脚本,支持启动,停止,重新启动等。(喜欢这里解释没有包装脚本),一个Java的.jar程序不能被管理为Linux上的服务.
If your java process was a tomcat server, as read in the comment, you could start it by manually by running
如果您的 java 进程是一个 tomcat 服务器,如评论中所读,您可以通过运行手动启动它
# catalina.sh start
Tomcat comes with wrapper scripts to run it as a service. If it was installed this way on your server, you could try to start it using
Tomcat 带有包装脚本以将其作为服务运行。如果它以这种方式安装在您的服务器上,您可以尝试使用
# sudo service tomcat8 start
See tomcat running documentationfor more info
有关更多信息,请参阅tomcat 运行文档