Skip to content

Instantly share code, notes, and snippets.

@morphkurt
Last active July 18, 2016 02:09
Show Gist options
  • Save morphkurt/e01fb207f6c5bf9c220531ce110b2fea to your computer and use it in GitHub Desktop.
Save morphkurt/e01fb207f6c5bf9c220531ce110b2fea to your computer and use it in GitHub Desktop.
Purging Script
#!/bin/bash
locations=/opt/purgescript/purgelocations
purge_days=7
log_location=/opt/purgescript/logs/delete_log
regex=".*\.\(mxf\|mp4\|avi\|mov\)"
function locate_files () {
for loc in `cat ${locations} | sed '/^$/d'`
do
date_f=`date +%Y"-"%m"-"%d" "%H":"%M":"%S`
echo "${date_f} Deleting the following files" >> ${log_location}
files=`find ${loc} -mtime +${purge_days} -iregex $regex -type f`
for l in ${files}
do
date_f=`date +%Y"-"%m"-"%d" "%H":"%M":"%S`
echo ${date_f} deleting ${l} >> ${log_location}
done
#find ${loc} -mtime +${purge_days} -iregex $regex -type f -delete
done
}
locate_files
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment