@echo off taskkill /F /IM nginx.exe > nul rem @echo off rem 取1天以前的日期 echo wscript.echo dateadd("d",-1,date) >%tmp%\tmp.vbs for /f "tokens=1,2,3* delims=/" %%i in ('cscript /nologo %tmp%\tmp.vbs') do set y=%%i for /f "tokens=1,2,3* delims=/" %%i in ('cscript /nologo %tmp%\tmp.vbs') do set m=%%j for /f "tokens=1,2,3* delims=/" %%i in ('cscript /nologo %tmp%\tmp.vbs') do set d=%%k if %m% LSS 9 set m=0%m% if %d% LSS 9 set d=0%d% echo %y%-%m%-%d% rem 設置 Nginx 位於的盤符 set NGINX_DRIVER=D: rem 設置 Nginx 的主目錄 set NGINX_PATH=%NGINX_DRIVER%\000_nginx-1.12.1 rem 設置 Nginx 的日誌目錄 set LOG_PATH=%NGINX_PATH%\logs rem 移動文件 move %LOG_PATH%\access.log %LOG_PATH%\access_%y%-%m%-%d%.log move %LOG_PATH%\error.log %LOG_PATH%\error_%y%-%m%-%d%.log rem 切換到 Nginx 所在的盤符 %NGINX_DRIVER% rem 進入 Nginx 的主目錄 cd %NGINX_PATH% rem 向 nginx 發送 reopen 信號以從新打開日誌文件,功能與 Linux 平臺中的 kill -USR1 一致 start nginx echo on
改爲bat文件,再加入到window定時任務中nginx