Created
October 3, 2014 05:29
-
-
Save jincod/85eef925e48dec5919f0 to your computer and use it in GitHub Desktop.
Powershell script for nginx log rotate
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Push-Location c:\nginx | |
.\nginx.exe -s stop | |
$started = ps nginx* | |
while($started) { | |
Start-Sleep 1 | |
$started = ps nginx* | |
} | |
Push-Location logs | |
$timestamp = (Get-Date).ToString("dd.MM.yyyy_HH.mm.ss") | |
$location = Get-Location | |
Move-Item "$location\access.log" "$location\archive\access_$timestamp.log" | |
Move-Item "$location\error.log" "$location\archive\error_$timestamp.log" | |
Pop-Location | |
start .\nginx.exe | |
Pop-Location |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment