Skip to content

Commit

Permalink
Minor fixes to expire_cache.sh cron script to handle special chars in
Browse files Browse the repository at this point in the history
filename.
  • Loading branch information
mikexstudios committed Aug 8, 2016
1 parent ad93800 commit 140aff7
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions conf/cron/expire_cache.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,21 @@
set -eo pipefail

# Get % of used disk space
THRESHOLD_PCT=95 #%. Above this % of used diskspace, cache is expired
THRESHOLD_PCT=90 #%. Above this % of used diskspace, cache is expired
USED_PCT=$(df -ah | grep "/usr/src/app" | head -n1 | awk '{print $5}' | sed 's/%$//')
if (( $USED_PCT < $THRESHOLD_PCT )); then
echo 'No need to prune. Exiting...'
exit #no need to prune
fi

# From: http://unix.stackexchange.com/a/29205
DELETE_LIMIT=2000 # number of oldest files deleted
DELETE_LIMIT=8000 # number of oldest files deleted
echo 'Pruning older cached files...'
while IFS= read -r -d $'\0' line ; do
file="${line#* }"

echo "Deleting $file..."
rm $file
rm "$file"

let DELETE_LIMIT-=1
[[ $DELETE_LIMIT -le 0 ]] && break
Expand Down

0 comments on commit 140aff7

Please sign in to comment.