@echo off
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%
rem echo %y%-%m%-%d%
rem 设置 Nginx 位于的盘符
set NGINX_DRIVER=E:
rem 设置 Nginx 的主目录
set NGINX_PATH=%NGINX_DRIVER%\hyc\Program Files\nginx-1.9.0
rem 设置 Nginx 的日志目录
set LOG_PATH=%NGINX_PATH%\logs
rem 切换到 Nginx 所在的盘符
%NGINX_DRIVER%
cd %LOG_PATH%
if not exist %y%-%m%-%d% (
mkdir %y%-%m%-%d%
)
rem 移动文件
move access.log %y%-%m%-%d%
move error.log %y%-%m%-%d%
rem 进入 Nginx 的主目录
cd %NGINX_PATH%
rem 向 nginx 发送 reopen 信号以重新打开日志文件,功能与 Linux 平台中的 kill -USR1 一致
nginx -s reopen
echo on
pause