简单的Windows Server 2008 Ngxin服务器启动/监控脚本

  • Ngxin启动/停止
1
2
3
4
5
6
7
8
9
10
11
12
13
14
@echo off
REM Windows 下无效
REM set PHP_FCGI_CHILDREN=5

REM 每个进程处理的最大请求数,或设置为 Windows 环境变量
set PHP_FCGI_MAX_REQUESTS=1000

echo Starting PHP FastCGI...
D:/wnmp/RunHiddenConsole D:/wnmp/php/php-cgi.exe -b 127.0.0.1:9001 -c D:/wnmp/php/php.ini
D:/wnmp/RunHiddenConsole D:/wnmp/php/php-cgi.exe -b 127.0.0.1:9002 -c D:/wnmp/php/php.ini
D:/wnmp/RunHiddenConsole D:/wnmp/php/php-cgi.exe -b 127.0.0.1:9003 -c D:/wnmp/php/php.ini
D:/wnmp/RunHiddenConsole D:/wnmp/php/php-cgi.exe -b 127.0.0.1:9004 -c D:/wnmp/php/php.ini
echo Starting nginx...
D:/wnmp/RunHiddenConsole D:/wnmp/nginx-1.8.1/nginx.exe -p D:/wnmp/nginx-1.8.1
1
2
3
4
5
6
7

@echo off
echo Stopping nginx...
taskkill /F /T /IM nginx.exe > nul
echo Stopping PHP FastCGI...
taskkill /F /T /IM php-cgi.exe > nul
exit
  • 简单实现服务器心跳检测BAT脚本
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
@echo off

:aaa

set str = "0"
echo request..
curl -sL -w %%{http_code} xxx.com:/admin/index -o /dev/null > check.txt

set /p str=<check.txt

if not "%str%"=="200" (
echo %date% %time:~0,5% is error>>check.log

echo. | call D:\wnmp\stop_nginx.bat
ping -n 3 127.0.0.1>nul
echo. | call D:\wnmp\start_nginx.bat
ping -n 3 127.0.0.1>nul
echo %date% %time:~0,5% start success>>check.log
)
ping -n 60 127.0.0.1>nul
goto aaa
  • VBS脚本
    1
    2
    3
    4

    DIM objShell
    set objShell=wscript.createObject("wscript.shell")
    iReturn=objShell.Run("cmd.exe /C cron.bat", 0, TRUE)