在nginx根目录,创建 split_log.bat
@echo off
rem 查看系统中正在运行的nginx进程
rem tasklist /fi "imagename eq nginx.exe"
rem 备份并根据时间重命名访问日志文件
set "cmdstr=move D:\nginx-1.5.11\logs\access.log D:\nginx-1.5.11\logs\access.%date:~0,4%-%date:~5,2%-%date:~8,2%.log
call %cmdstr%"
rem 备份并根据时间重命名错误日志文件
set "cmdstr=move D:\nginx-1.5.11\logs\error.log D:\nginx-1.5.11\logs\error.%date:~0,4%-%date:~5,2%-%date:~8,2%.log
call %cmdstr%"
rem re-opening log files
nginx -s reopen
在windows下添加一个任务计划,每天执行一次即可。(windows server 2003 中的任务计划在附件-系统工具中)
注:[alert]: CreateFileMapping(1024, nginx_shared_zone) failed (5: Access is denied)