Real-time monitoring of the status of Tomcat service, if you turn off automatically open (resolved)

A few days ago I wrote a real-time monitoring of tomcat script , before the detection of tomcat process exists, if does not exist, open the start.bat . But when the project deployment (my project deployed in the Windows system), tomcat sometimes automatically shut down, but in the open with start.bat, running for some time, the return of Java (TM) Platform SE binary has stopped working

Cause the script detects that the process is closed, can not open the tomcat normal. So I open the service with a way to open the tomcat,

What is the state detection script tomcat services running, if tomcat service is shut down, it automatically turns on.

@echo off
rem defined cycle time interval (10s) and monitoring services:
set secs=10
set srvname="Tomcat8"


echo.
echo ======================================== 
echo == status inquiry computer services, == 
echo == intervals% secs% seconds a query, == 
echo == found it to stop, then start immediately. == 
echo ========================================
echo.
echo This script monitoring service is: %% srvname
echo.


if %srvname%. == . goto end


: Chkit
set svrst=0
for /F "tokens=1* delims= " %%a in ('net start') do if /I "%%a %%b" == %srvname% set svrst=1
if %svrst% == 0 net start %srvname%
set svrst=
rem The following commands are used to delay, otherwise it could lead to a single core cpu full.
ping -n %secs% 127.0.0.1 > nul
goto chkit


:end

Get the source code and script file feet, please pay attention to the public number "  IT resource sharing platform  " or two-dimensional code scan the upper right corner to send the keyword " Q4 ", a project will share practical resources every day.

Amway a resource site: View

Guess you like

Origin www.cnblogs.com/alex96/p/12227218.html