问题描述
我有一个Java程序,我想在Linux系统上守护进程。换句话说,我想开始在shell中运行它,并在我退出后继续运行它。我也希望能够干净地停止这个程序。
I have a Java program that I'd like to daemonize on a linux system. In other words, I want to start running it in a shell and have it continue running after I've logged out. I also want to be able to stop the program cleanly.
我找到了使用shell脚本和Java代码的组合来完成这一操作。它看起来不错,但如果可能的话,我想要更简单的东西。
I found this article which uses a combination of shell scripting and Java code to do the trick. It looks good, but I'd like something simpler, if possible.
在Linux系统上守护Java程序的首选方法是什么?
What's your preferred method to daemonize a Java program on a Linux system?
推荐答案
将您的Java程序作为Linux守护程序或WinNT服务运行。
Apache Commons Daemon will run your Java program as Linux daemon or WinNT Service.
这篇关于如何守护Java程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!