Skip to content

Instantly share code, notes, and snippets.

@chill117
Created August 15, 2013 19:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save chill117/6244241 to your computer and use it in GitHub Desktop.
Save chill117/6244241 to your computer and use it in GitHub Desktop.
Automatically delete old backup files.
#!/bin/bash
#
# Use this script to automatically delete old backup files.
#
declare -i max_age
# Number of days to keep backup files.
max_age=10
# Location of backup files.
backups_dir="/home/backups/db/"
for file in $(find $backups_dir -mtime +$max_age); do
rm "$file";
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment