windows下脚本检测tomcat是否启动,没有启动则启动

时间:2023-03-09 19:43:31
windows下脚本检测tomcat是否启动,没有启动则启动

最近有个服务需要部署到windows server2003上面,机房没有windows ser的机器,没办法搞了个阿里云服务,购买的配置比较低,

不知道什么原因,tomcat启动后总是容易自动退出,搞了个脚本检测tomcat是否启动状态,没有启动则启动。然后放入定时任务每隔5分钟跑一次,

脚本如下:

@echo off
title Tomcat重啟脚本

ping -n 6 127.1 >nul
wmic process where name="java.exe" get processid,commandline |findstr /i "tomcat" >#
setlocal enabledelayedexpansion
for /f "delims=*" %%i in (#) do (
set var=%%i
set var=!var:start =#!
for /f "tokens=2 delims=#" %%a in ("!var!") do (
set tomcatpid=%%a
)
)
del # >nul
if not defined tomcatpid call "c:\websoft\tomcat\Tomcat7_site\bin\startup.bat"