Skip to content

Instantly share code, notes, and snippets.

@jincod
Created October 3, 2014 05:29
Show Gist options
  • Save jincod/85eef925e48dec5919f0 to your computer and use it in GitHub Desktop.
Save jincod/85eef925e48dec5919f0 to your computer and use it in GitHub Desktop.
Powershell script for nginx log rotate
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