Last active
July 18, 2016 02:09
-
-
Save morphkurt/e01fb207f6c5bf9c220531ce110b2fea to your computer and use it in GitHub Desktop.
Purging Script
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 | |
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