您的位置:首页 > 运维架构 > Nginx

Windows下Nginx日志分割

2016-07-14 19:18 316 查看
@echo off

rem check nginx task list in system

rem tasklist /fi “imagename eq nginx.exe”

rem taskkill /F /IM nginx.exe

rem get time in format

set dst=%date:~6,4%%date:~0,2%%date:~3,2%

rem rename and backup km download log

set “cmdstr=move D:\nginx-1.8.0\logs\svckb_access.log D:\nginx-1.8.0\logs\%dst%svckb_access.log

call %cmdstr%”

rem rename and backup km access log

set “cmdstr=move D:\nginx-1.8.0\logs\svckb_access.log D:\nginx-1.8.0\logs\%dst%svckm_access.log

call %cmdstr%”

rem rename and backup wcf service access log

set “cmdstr=move D:\nginx-1.8.0\logs\st_access.log D:\nginx-1.8.0\logs\%dst%st_access.log

call %cmdstr%”

rem rename and backup error log

set “cmdstr=move D:\nginx-1.8.0\logs\error.log D:\nginx-1.8.0\logs\%dst%error.log

call %cmdstr%”

rem delete log in 7 days before

forfiles /p “D:\nginx-1.8.0\logs” /s /m *.log /d -7 /c “cmd /c del @path”

rem re-opening log files

nginx -s reopen

echo on

Notice:

date format may be different in each system
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  nginx