programmazione:logrotate
Differences
This shows you the differences between two versions of the page.
| programmazione:logrotate [28/09/2026 04:21] – created lrosa | programmazione:logrotate [28/09/2026 04:22] (current) – lrosa | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ====== Cancellazione vecchi file di log ====== | ====== Cancellazione vecchi file di log ====== | ||
| - | # 15 giorni | + | |
| - | $limit = (Get-Date).AddDays(-15) | + | $limit = (Get-Date).AddDays(-15) |
| - | $path = " | + | $path = " |
| - | + | ||
| - | # Cancella i vecchi file | + | # Cancella i vecchi file |
| - | Get-ChildItem -Path $path -Recurse -Force | Where-Object { !$_.PSIsContainer -and $_.CreationTime -lt $limit } | Remove-Item -Force | + | Get-ChildItem -Path $path -Recurse -Force | Where-Object { !$_.PSIsContainer -and $_.CreationTime -lt $limit } | Remove-Item -Force |
| - | + | ||
| - | # Cancella anche le directory vuote | + | # Cancella anche le directory vuote |
| - | Get-ChildItem -Path $path -Recurse -Force | Where-Object { $_.PSIsContainer -and (Get-ChildItem -Path $_.FullName -Recurse -Force | Where-Object { !$_.PSIsContainer }) -eq $null } | Remove-Item -Force -Recurse | + | Get-ChildItem -Path $path -Recurse -Force | Where-Object { $_.PSIsContainer -and (Get-ChildItem -Path $_.FullName -Recurse -Force | Where-Object { !$_.PSIsContainer }) -eq $null } | Remove-Item -Force -Recurse |
programmazione/logrotate.1790569312.txt.gz · Last modified: by lrosa
