Last active
December 21, 2015 03:29
-
-
Save Firefishy/6242302 to your computer and use it in GitHub Desktop.
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 | |
| 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