一个windows计划任务的Nginx日志自动截断的批处理命令

时间:2024-10-16 22:05:50
net stop nginx

taskkill /im nginx.exe /f

cd E:\nginx
e: set NO=%Date:~0,4%%Date:~5,2%%Date:~8,2%
set t=%Time%
if "%t:~0,1%" ==" " (
set t=0%t:~1%
)
set NO=%Date:~0,4%%Date:~5,2%%Date:~8,2%%t:~0,2%%t:~3,2%%t:~6,2% move logs\access.log bak\access_%no%.log
move logs\error.log bak\error_%no%.log
copy nul logs\access.log
copy nul logs\error.log net start nginx pause