nginx log日志分割

时间:2023-02-09 09:10:04

@echo off
rem 备份并根据时间重命名错误日志文件
set "cmdstr=move E:\nginx\logs\error.log E:\nginx\logs\error%date:~0,4%-%date:~5,2%-%date:~8,2%.log
call %cmdstr%"
rem re-opening log files
rem 重新打开nginx
nginx -s reopen
rem 删除1天之前的备份
forfiles /p E:\nginx\logs /s /m *.log /d -1 /c "cmd /c del @path"

将以上脚本保存成.bat脚本文件,加Windows定时任务。