User Tools

Site Tools


programmazione:logrotate

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

programmazione:logrotate [28/09/2026 04:21] – created lrosaprogrammazione:logrotate [28/09/2026 04:22] (current) – lrosa
Line 1: Line 1:
 ====== Cancellazione vecchi file di log ====== ====== Cancellazione vecchi file di log ======
  
-# 15 giorni +  # 15 giorni 
-$limit = (Get-Date).AddDays(-15) +  $limit = (Get-Date).AddDays(-15) 
-$path = "C:\Some\Path" +  $path = "C:\Some\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