Skip to content

Instantly share code, notes, and snippets.

@Firefishy
Last active December 21, 2015 03:29
Show Gist options
  • Select an option

  • Save Firefishy/6242302 to your computer and use it in GitHub Desktop.

Select an option

Save Firefishy/6242302 to your computer and use it in GitHub Desktop.
#!/bin/bash
set +e
#fixme loop on folders in use
#fixme add global timeout
olderthanstart=90 #start cleaning older than
olderthanend=70 #end cleaning older than
diskcleanlevel=60 #target disk usage %
cleanuptimeout="1h"
olderthan=${olderthanstart}
usagedisk=$(df -P /store/tiles/default-high| grep -vE '^Filesystem' | awk '{ print $5 }'|cut -d '%' -f 1)
while [ "${olderthan}" -ge "${olderthanend}" ] && [ "${usagedisk}" -ge "${diskcleanlevel}" ]; do
echo "Cleaning older than ${olderthan} days"
#fixme timeout part of coreutils, find correct?
#timeout ${cleanuptimeout} find /store/tiles/default-high -xdev -type f -name '*.meta' -atime +${olderthan} -ctime +${olderthan} -delete
olderthan=$((olderthan - 1))
usagedisk=$(df -P /store/tiles/default-high| grep -vE '^Filesystem' | awk '{ print $5 }'|cut -d '%' -f 1)
done
if [ "${usagedisk}" -ge "${diskcleanlevel}" ]; then
echo "Usage Still Exceeds ${diskcleanlevel}% on /store/tiles/default-high"
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment