Skip to content

Instantly share code, notes, and snippets.

@elchappo
Created October 20, 2012 22:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save elchappo/3925109 to your computer and use it in GitHub Desktop.
Save elchappo/3925109 to your computer and use it in GitHub Desktop.
PHP resizer sentinel
#!/bin/bash
CACHEDIR=
MAXSIZE=100
DIRSIZE=`du -s $CACHEDIR | cut -f 1`
MINFILES=5
echo $DIRSIZE' : '$CACHEDIR
#ls -t cache | sed -e '1,10d' | xargs -d '\n' rm
if [ $DIRSIZE -gt $MAXSIZE ]; then
echo 'Removing files...'
find $CACHEDIR -maxdepth 1 -mindepth 1 -printf '%T+ %p\n' | sort -r | tail -n +$MINFILES | xargs rm -rf
echo 'Done'
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment