(1)goto命令執行迴圈
(2)tasklist|findstr -i "mysqld.exe"
檢測程序是否存在
(3)start "" "d:/a_wnmps/webserver/mysql/bin/mysqld.exe"
執行命令,後面的第乙個"",用來允許第二個"..."中有空格
(4)執行不同目錄下的bat,兩步
1.先 cd /d "d:\a_wnmps\webserver\nginx" // 跳轉目錄
2.再 call start_nginx.bat // 執行bat檔案
最後,cd /d "d:\a_file" // 返回原來的目錄,不然命令列上沒東西
(5)choice /t 300 /d y /n > nul
延時,/t後面的300指300秒,也可以用:
ping -n 300 127.0.0.1 >nul 延時,-n後面的300指300秒
@echo off
title restart bbs
:again
tasklist|findstr -i "mysqld.exe"
if errorlevel 1 (
echo mysqld is off in %date:~0,4%-%date:~5,2%-%date:~8,2% %time:~0,2%:%time:~3,2%
start "" "d:/a_wnmps/webserver/mysql/bin/mysqld.exe"
)tasklist|findstr -i "nginx.exe"
if errorlevel 1 (
echo nginx is off in %date:~0,4%-%date:~5,2%-%date:~8,2% %time:~0,2%:%time:~3,2%
cd /d "d:\a_wnmps\webserver\nginx"
call start_nginx.bat
)tasklist|findstr -i "xxfpm.exe"
if errorlevel 1 (
echo xxfpm is off in %date:~0,4%-%date:~5,2%-%date:~8,2% %time:~0,2%:%time:~3,2%
cd /d "c:\users\administrator\desktop\xxfpm\bin"
call start_xxfpm.bat
)cd /d "d:\a_file"
choice /t 300 /d y /n > nul
goto again
windows下bat實現監控程序
echo off checkservice for f tokens 5 n in qprocess.exe find supernode.exe do if n supernode.exe goto checkmessage else goto restartservice restartserv...
windows下bat批處理實現守護程序
最近幾天加班加瘋掉了,天天晚上沒法睡。開發部的乙個核心程式總是會自己宕機,然後需要手工去起,而這個服務的安全級別又很高,只有我可以操作,搞得我晚上老沒法睡,昨晚實在受不了了,想起以前在hp ux下寫的shell守護程序,這回搞個windows下的bat版守護程式吧,當時晚上思路已經很遲鈍了,就叫了個...
windows下bat批處理實現守護程序
最近幾天加班加瘋掉了,天天晚上沒法睡。開發部的乙個核心程式總是會自己宕機,然後需要手工去起,而這個服務的安全級別又很高,只有我可以操作,搞得我晚上老沒法睡,昨晚實在受不了了,想起以前在hp ux下寫的shell守護程序,這回搞個windows下的bat版守護程式吧,當時晚上思路已經很遲鈍了,就叫了個...