Rotating Access Logs with $date_local

itpp2012 nginx-forum at
Tue Oct 28 19:06:00 UTC 2014


@echo off
::Parse the time variable into timeStamp
FOR /F "tokens=1-4 delims=/:., " %%J IN ("%time%") DO SET
::Parse the date variable into dateStamp, YYYYMMDD
FOR /F "tokens=2-4 delims=/:.- " %%J IN ("%date%") DO SET
set datename=%dateStamp%
::Parse the name again and get rid of the spaces
FOR /F "tokens=1-4" %%J IN ("%datename%") DO SET datename=%%J%%K%%L
IF "%datename%"=="" set datename=EMPTY

cd /d x:\logs
FOR %%G IN (*.log) DO ren "%%G" "%datename%_%%G"

choice /t:y,5
cd /d c:\nginx
runas /savecred /env /user:nginxserviceuser "nginx -s reopen"
choice /t:y,5

cd /d x:\logs
move /y %datename%_*.* x:\archives\logdata

Posted at Nginx Forum:,254367,254382#msg-254382

More information about the nginx mailing list