From 65c58da0f2cd881c5559721519e9cb1e52bde7b1 Mon Sep 17 00:00:00 2001 From: Vladislav Salikov Date: Sun, 15 Dec 2024 13:15:19 +0300 Subject: [PATCH] Moved wDayzManager logs rotation. Moved wDayzManager logs rotation from servers start loop to outside. --- wDayzManager.ps1 | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/wDayzManager.ps1 b/wDayzManager.ps1 index 25ddf70..97d7723 100644 --- a/wDayzManager.ps1 +++ b/wDayzManager.ps1 @@ -1,4 +1,4 @@ -# wDayzManager v0.1 +# wDayzManager v0.2 # Copyright (c) 2024 Vladislav Salikov aka W0LF aka 'dreamforce' # https://github.com/dreamforceinc # Required module: PSIni @@ -226,6 +226,17 @@ if ($rotateLogs) { $daysAmount = [Math]::Abs($config.daysAmount) if (-not ([string]::IsNullOrEmpty($config.rotatedLogsFolderName))) { $rotatedLogsFolderName = $config.rotatedLogsFolderName + + Write-Host "Removing old wDayzManager logs..." + $fileList = $null + $fileList = Get-ChildItem -Path $currentPath\*.log -Recurse | Where-Object { $_.LastWriteTime.Date -lt $date.AddDays( -3) } + # Write-Host $fileList -Separator "`n" + foreach ($file in $fileList) { + Remove-Item -Path $file + Write-Host "Removed $($file)!" + } + Write-Host "Total: $($fileList.Count)" + Write-Host } else { Write-Error "The 'rotatedLogsFolderName' parameter not set!" @@ -436,20 +447,6 @@ foreach ($srv in $servers) { Write-Host } #endregion - - #region ### wDayzManager ### - Write-Host "Removing old wDayzManager logs..." - - $fileList = $null - $fileList = Get-ChildItem -Path $currentPath\*.log -Recurse | Where-Object { $_.LastWriteTime.Date -lt $date.AddDays( -3) } - # Write-Host $fileList -Separator "`n" - foreach ($file in $fileList) { - Remove-Item -Path $file - Write-Host "Removed $($file)!" - } - Write-Host "Total: $($fileList.Count)" - Write-Host - #endregion } # Write-Host " instance: $($instance)"