Windows下Nginx日志分割

来源:互联网 发布:淘宝企业店铺怎么注销 编辑:程序博客网 时间:2024/05/15 09:39

@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

0 0
原创粉丝点击