Skip to content

Setup logrotate for nginx under windows

Create a batch script for the logrotate and save it as nginx_logrotate.bat


rem get date in format ddMMyyyyhhmmss
set dt=%DATE:~6,4%%DATE:~3,2%%DATE:~0,2%%TIME:~0,2%%TIME:~3,2%%TIME:~6,2%
set dt=%dt: =0%
rem move the current logfiles
move F:\Programme\nginx\logs\Access.log F:\Programme\nginx\logs\Access%dt%.log
move F:\Programme\nginx\logs\Error.log F:\Programme\nginx\logs\Error%dt%.log
rem tell nginx to write new logfiles
cd F:\Programme\nginx\
call F:\Programme\nginx\nginx.exe -p F:\Programme\nginx\ -s reopen

Then you can create a basic windows scheduler task which starts this batch script.

If you run nginx as a windows service, make sure to execute the windows scheduler with the same user as the nginx windows service is running.


When you’re getting the following error:  could not open error log file: CreateFile() "F:\Programme\nginx\nginx.exe/logs/error.log" failed (3: The system cannot find the path specified), make sure to not add nginx.exe to the –p parameter value

Trackbacks

No Trackbacks

Comments

Display comments as Linear | Threaded

Custom essay writing service on :

Well, this is my first visit to your blog! But I admire the precious time and effort you put into it, especially into interesting articles you share here!

CourseworkGeek.co.uk on :

I've discovered a lot of references on the web for pivoting the Nginx logs under Linux.. simply send the USR1 flag to the procedure. However... Unix like signs don't exist on windows and I haven't possessed the capacity to discover any data on this. How might I achieve a similar thing with nginx on windows??

www.courseworkbuzz.co.uk on :

It had particular necessity to stop , then duplicate log documents and after that restart benefit nighly premise. You can download the code and change it the way you need.

CourseworkHelpPros.co.uk on :

With courseworkhelppros web-based composition administrations, you don't have to look anyplace else as we are working round the clock to give you some assistance at your season of scholarly needs. Our written work organization has the best profile keeping in mind the end goal to supply you with quality coursework satisfying all your custom necessities

Add Comment

You can use [geshi lang=lang_name [,ln={y|n}]][/geshi] tags to embed source code snippets.
Markdown format allowed
Form options