This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#clean recursively all files older than 180 days in the given path | |
$filterDate = (Get-Date).AddDays(-180).Date | |
Get-ChildItem E:\DIR_PATH -Directory | ForEach-Object { | |
Get-ChildItem $_.FullName -Recurse | Where {$_.lastwriteTime.Date -le $filterDate } | Remove-Item | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
baseDir="/path" | |
# On compte le nombre d'archive presente dans le dossier | |
NbArchive=$(ls -A $baseDir | wc -l) | |
# Si il y a plus de 15 archives, on supprime la plus ancienne | |
while [ "$NbArchive" -gt 15 ];do | |
# On recupere l'archive la plus ancienne | |
Old_backup=$(ls -lrt $baseDir | head -n 2 | tail -n 1 | cut -d ":" -f 2 | cut -d " " -f 2) |
OlderNewer