@echo off
REM This script is designed to complete Nginx Service log scrolling
REM Nginx working directory
Set Workspace=d:\niis\nginx
REM Log storage Directory
Set Logdir=d:\niis\nginx\logs
REM view of Nginx processes running in the system
rem tasklist/fi "imagename eq nginx.exe"
REM Log storage path. The directory structure of the saved log is: Year \ month \ Day
Set rolldir=%logdir%\%date:~0,4%\%date:~5,2%\%date:~8,2%
Set MDROLLDIR=MD%rolldir%
Call%mdrolldir%
REM Backup and rename access log files based on time
The REM log file name format is: Access. Year-month-day-hour. Log
Set Cmdstr=move%logdir%\access.log%rolldir%\access.%date:~0,4%-%date:~5,2%-%date:~8,2%-%time:~0,2%.log
Call%cmdstr%
REM Backup and rename error log files based on time
The REM log file name format is: Access. Year-month-day-hour. Log
Set Cmdstr=move%logdir%\error.log%rolldir%\error.%date:~0,4%-%date:~5,2%-%date:~8,2%-%time:~0,2%.log
Call%cmdstr%
REM Reopen log file
%workspace%\nginx.exe-s reopen-p%workspace%
This article is from "Lao Wang Linux Journey" blog, please be sure to keep this source http://oldking.blog.51cto.com/10402759/1941039
Windows Nginx Log Scrolling