我想使用批处理文件重启远程tomcat实例。有可能吗?
流量:
Stop tomcat
execute some sql script
start tomcat
有可能吗?如果是这样,你能否给我一些见解来实现这个目标?
谢谢!
答案 0 :(得分:2)
当然有可能。 在我的头顶:
startup
,shutdown
,catalina
)来控制tomcat。文件扩展名取决于平台(Windows的.bat
,Unix的.sh
答案 1 :(得分:0)
您可以远程部署,启动,停止和重新启动tomcat。为此,您必须执行以下步骤:
如何远程操作tomcat,您可以使用以下链接:
答案 2 :(得分:0)
我编写了一个ant build脚本,它将重启tomcat并清除tomcat缓存。只需将xml文件放入tomcat / bin即可。用于等待服务器停止的代码似乎并不适用于所有系统,因此我只添加了一个等待3分钟的目标。
{代码}
<property name="startServer.dir" value="." />
<property name="startServer.cmd.unix" value="startup.sh"/>
<property name="startServer.cmd.windows" value="startup.bat"/>
<property name="stopServer.cmd.unix" value="shutdown.sh"/>
<property name="stopServer.cmd.windows" value="shutdown.bat"/>
<property name="maven.port" value="8080"/>
<property name="deployed.cache" value="../work"/>
<!-- stop web server targets -->
<target name="stop" depends="" description="stop app server which is configured on this system">
<echo message="Attempting to stop app server ${startServer.dir}"/>
<echo message="${stopServer.cmd.unix} / ${stopServer.cmd.windows}"/>
<exec dir="${startServer.dir}" osfamily="unix" executable="sh" timeout="18000">
<arg line="${stopServer.cmd.unix}"/>
</exec>
<exec dir="${startServer.dir}" osfamily="windows" executable="cmd" timeout="18000">
<arg line="/c ${stopServer.cmd.windows}"/>
</exec>
<echo message="waiting for server to stop"/>
<waitfor maxwait="5" maxwaitunit="minute" checkevery="500">
<not>
<http url="http://localhost:${maven.port}"/>
</not>
</waitfor>
</target>
<target name="pause">
<echo message="Pausing for 3 minutes to make sure server is stopped" />
<sleep minutes="3"/>
</target>
<!-- start web server targets -->
<target name="start" description="start app server which is configured on this system">
<echo message="Attempting to start app server server ${startServer.dir}"/>
<echo message="${startServer.cmd.unix} / ${startServer.cmd.windows}"/>
<exec dir="${startServer.dir}" osfamily="unix" executable="sh" spawn="true">
<arg line="${startServer.cmd.unix}"/>
</exec>
<exec dir="${startServer.dir}" osfamily="windows" executable="cmd" spawn="true">
<arg line="/c ${startServer.cmd.windows}"/>
</exec>
</target>
<target name="cleanTomcat" description="Remove tomcat cashe">
<delete dir="${deployed.cache}" verbose="true"/>
</target>
<target name="restart" depends="stop,pause,cleanTomcat,start"/>
{代码}