Skip to content

Instantly share code, notes, and snippets.

@24HOURSMEDIA
Created March 31, 2014 09:49
Show Gist options
  • Save 24HOURSMEDIA/9888936 to your computer and use it in GitHub Desktop.
Save 24HOURSMEDIA/9888936 to your computer and use it in GitHub Desktop.
delete backuop files older than 90 days
#!/bin/sh
#
# Delete backup more than 90 days old.
#
backupDir="/var/lib/psa/dumps/tmp"
#
daysToKeep=90
echo "Checking for files older than $daysToKeep days in $backupDir"
listOfFiles=`find $backupDir -mtime +$daysToKeep`
if [ ! -z $listOfFiles ]
then
echo "Found [$listOfFiles]"
else
echo "None found."
fi
for toDelete in $listOfFiles
do
echo "Deleting $toDelete"
rm -rf $toDelete
done
echo "Done."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment