系统相关
首页 > 系统相关> > nginx 日志切割

nginx 日志切割

作者:互联网

 

 

windows: 

1、建一个Bat文件如下。

2、设置定时执行Bat方法

@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

 

标签:-%,set,切割,nginx,dir%,date,日志,log
来源: https://www.cnblogs.com/xiaoruilin/p/16095343.html