写一个下边的bat脚本,然后将bat加入系统执行计划即可。
@echo
taskkill /F /IM nginx.exe > nul
set homedir=D:\nginx-1.9.9
d:
cd %homedir%
rem date format:20191211
set today=%date:~0,4%%date:~5,2%%date:~8,2%
set /a yesterday=%today%-1
set logdir=%homedir%\logs\%yesterday%
md %dir%
rem access log
move %homedir%\logs\*.log %logdir%\
start nginx
rem delete old logs dir
set /a deletedaydir=%today%-7
rd /s /q %homedir%\logs\%deletedaydir%
网友评论