BAT批处理判断服务是否正常运行的方法(批处理命令综合应用)(bat批处理命令运行程序)真没想到

随心笔谈2年前发布 编辑
187 0
🌐 经济型:买域名、轻量云服务器、用途:游戏 网站等 《腾讯云》特点:特价机便宜 适合初学者用 点我优惠购买
🚀 拓展型:买域名、轻量云服务器、用途:游戏 网站等 《阿里云》特点:中档服务器便宜 域名备案事多 点我优惠购买
🛡️ 稳定型:买域名、轻量云服务器、用途:游戏 网站等 《西部数码》 特点:比上两家略贵但是稳定性超好事也少 点我优惠购买


@echo off
color 2E
set YYYYmmdd=%date:~0,4%%date:~5,2%%date:~8,2%
set hhmiss=%time:~0,2%%time:~3,2%%time:~6,2%
set filename=healthcheck.log
REM set “filename=healthcheck_%YYYYmmdd%_%hhmiss%.log”
set “datetime=%YYYYmmdd%%hhmiss%”
set allCount=0
set errorCount=0
set checkList=”QlikSenseServiceDispatcher” “QlikSenseSchedulerService” “QlikSenseRepositoryService” “QlikSenseRepositoryDatabase” “QlikSenseProxyService” “QlikSensePrintingService” “QlikSenseEngineService” “QlikLoggingService”
echo============================================>%filename%
echo Health Checking by Qlik Team >>%filename%
echo zhengkai.blog.csdn.net
echo (datetime: %datetime% ) >>%filename%
echo============================================>>%filename%
echo. >>%filename%
echo. >>%filename%
for %%L in (%checkList%) do call :health_check %%L
echo============================================>>%filename%
echo Checking Finish. >>%filename%
echo. >>%filename%
echo Error : %errorCount% of %allCount% >>%filename%
echo. >>%filename%
echo============================================>>%filename%
call :check_status
echo============================================>>%filename%
goto:end

:health_check
sc query |find /i %1 >nul 2>nul
if not errorlevel 1 (
echo SUCCESS…… %1 >>%filename%
)else (
echo FAILD…… %1 is error ! >>%filename%
set /a errorCount+=1
)
set /a allCount+=1
goto:eof

:check_status
if %errorCount% gtr 0 (
echo ###### this server is Not Health >>%filename%
) else (
echo ###### this server is Health >>%filename%
)
goto:eof

:end
copy %filename% \\xxxx\DataShare\CSDN\ZhengKai\

© 版权声明

相关文章