从命令行将java_opts设置为tomcat服务 [英] Setting java_opts to tomcat service from command line

查看:509
本文介绍了从命令行将java_opts设置为tomcat服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Windows上运行了tomcat7服务, 通常为了配置Java选项,我转到Tomcat 7.0 \ bin \ tomcat7w.exe,然后在Java选项卡中找到,在Java选项中,我会打印所需的定义,例如-javaagent:.... 我想通过命令行或使用一些脚本使其自动化,有什么方法可以实现并且仍然将tomcat作为服务运行? (现在我通过cmd运行tomcat:"sc tomcat7 start").

I have a tomcat7 service running on windows, Usually in order to configure the Java options I go to Tomcat 7.0\bin\tomcat7w.exe and there in java tab, in java options I print the definition I want, for example -javaagent:... I want to do this through command line or using some script to have it automated, is there any way to achieve this and still run the tomcat as a service? (right now I run tomcat through cmd: "sc tomcat7 start").

谢谢

推荐答案

请参见 http://tomcat.apache.org/tomcat-7.0-doc/windows-service-howto.html#Updating_services

您可以运行以下内容(第一个"tomcat7.exe"是服务可执行文件的名称,第二个"//US//tomcat7"是前缀为//US//的服务名称,表示更新服务"):

You can run something like the following (the first "tomcat7.exe" is the service executable name, and the second "//US//tomcat7" is the service name prefixed with //US//, meaning "update service"):

tomcat7.exe //US//tomcat7 "--JvmOptions=-Xrs;-javaagent:xyz"

通过--JvmOptions标志传递的值是用分号分隔的JAVA_OPTS标志.如果您在服务未运行时(即在执行之前)执行此操作,

The values passed with the --JvmOptions flag are semicolon separated JAVA_OPTS flags. If you do this while the service is not running, i.e. before you execute:

sc.exe tomcat7 start

然后它将影响该"tomcat7" Tomcat服务的后续启动.

then it will affect subsequent starts of that "tomcat7" Tomcat service.

这篇关于从命令行将java_opts设置为tomcat服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆