keep log files for 120 days
This commit is contained in:
@@ -37,8 +37,8 @@ Function Setup-LogFile {
|
|||||||
$LogFilePostfix = Get-LongDateTime
|
$LogFilePostfix = Get-LongDateTime
|
||||||
$Global:LogFile = "${LogsDirectory}\${LogFilePrefix}_${LogFilePostfix}.log"
|
$Global:LogFile = "${LogsDirectory}\${LogFilePrefix}_${LogFilePostfix}.log"
|
||||||
|
|
||||||
## Delete log files older than 30 days
|
## Delete log files older than 120 days
|
||||||
$LogFileAllowedAge = (Get-Date).AddDays(-30)
|
$LogFileAllowedAge = (Get-Date).AddDays(-120)
|
||||||
Try {
|
Try {
|
||||||
Get-ChildItem -Path "${LogsDirectory}\${LogFilePrefix}_*.*" -Filter '*.log' | `
|
Get-ChildItem -Path "${LogsDirectory}\${LogFilePrefix}_*.*" -Filter '*.log' | `
|
||||||
Where-Object {$_.LastWriteTime -lt $LogFileAllowedAge} | `
|
Where-Object {$_.LastWriteTime -lt $LogFileAllowedAge} | `
|
||||||
|
|||||||
Reference in New Issue
Block a user