nginx 日志切割

 

 

windows: 

1、建一个Bat文件如下。

2、设置定时执行Bat方法:https://www.cnblogs.com/bmwchampion/archive/2010/08/21/autotimingexcutejob.html

@echo off

set basedir=%~dp0
set logdir=%~dp0\logs
set dir=%logdir%\backup
set nginxSer="Nginx Service"

cd basedir
net stop %nginxSer% >nul
taskkill /F /IM nginx.exe > nul
rem date格式:Wed 11/02/2016
set today=%date:~0,4%-%date:~5,2%-%date:~8,2%

if not exist "%dir%" md "%dir%"

rem access log 
move "%logdir%\access.log" "%dir%\access-%today%.log"

::start nginx
net start %nginxSer%
pause

 

posted @ 2022-04-03 10:51  三瑞  阅读(30)  评论(0编辑  收藏  举报