简体   繁体   English

将Java jar文件作为守护程序运行并指定pid路径

[英]Running java jar file as a daemon and specify pid path

I'm running CentOS 6 and I have a jar file I'd like to execute with java and have it run in the background. 我正在运行CentOS 6,并且有一个jar文件,我想使用Java执行该文件,并使其在后台运行。 I plan on executing this command from a script, and I also would like to specify the path at which the pid file is output. 我计划从脚本执行此命令,并且我还想指定pid文件的输出路径。 How can I do all this? 我该怎么办?

You can use Java Service(Commons Daemon) from apache. 您可以从apache使用Java Service(公共守护程序) Instead of implementing main , your class to execute must provide method for the service execution ( start , stop , etc.) 除了执行main ,要执行的类还必须提供用于服务执行的方法( startstop等)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM