http ping 重启服务

http ping 重启服务

此工具检查网站是否离线。 http://www.coretechnologies.com/products/http-ping/

我正在尝试创建一个自动化流程来运行该文件并检查domain.com,如果ping失败则停止-->启动apache。

他们的网站上有一个示例代码,我稍加修改后,看起来像,

@echo off
REM This batch file is for use with AlwaysUp (http://www.coretechnologies.com/products/AlwaysUp/) or Service Protector (http://www.coretechnologies.com/products/ServiceProtector/)
REM Copyright � 2001-2012 Core Technologies Consulting, LLC. All rights reserved.


REM Ping your web server
REM *** Please change the location of http-ping.exe if necessary and adjust the URL to point to your web server ***
"C:\http-ping.exe" http://www.domain.com

REM http-ping returns the percentage of pings that succeed. With 4 attempts, this can be 0, 25, 50, 75, or 100.
REM Any of the 4 pings succeeds consider it a success ==> return 0 so that AlwaysUp doesn't restart
IF ERRORLEVEL 25 GOTO success
IF ERRORLEVEL 50 GOTO success
IF ERRORLEVEL 75 GOTO success
IF ERRORLEVEL 100 GOTO success

REM Exit code of 0 ==> all failed ==> return 1 to have AlwaysUp restart the application
IF ERRORLEVEL 0 GOTO failure


REM http-ping returned a code < 0 ==> there was some other kind of failure. Don't restart, but have AlwaysUp log the failure ==> return 2
echo http-ping failed!
net stop Apache2.4
net start Apache2.4
exit 2

:success
echo Succeeded!
exit 0

:failure
echo Failed!
net stop Apache2.4
net start Apache2.4
exit 1

但它不起作用。使用 Windows、Apache,我正在使用操作系统中的计划功能来自动化它。

常规的 Windows ping 实用程序无法满足我的需求。

感谢任何帮助。

相关内容