Skip to content

Instantly share code, notes, and snippets.

@ngfw
Last active December 26, 2015 20:29
Show Gist options
  • Save ngfw/7209299 to your computer and use it in GitHub Desktop.
Save ngfw/7209299 to your computer and use it in GitHub Desktop.
Clear cache files with cron
#!/bin/bash
# Params
# Remove Files Every N Min
MINUTESTOKEEPFILES=2880
# DO NOT EDIT BELOW THIS LINE
SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ]; do
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
SOURCE="$(readlink "$SOURCE")"
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE"
done
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
# Find And Remove Files
nice -n 39 find $DIR -type f -name "*.cache" -mmin +$MINUTESTOKEEPFILES -delete
nice -n 39 find $DIR -type f -name "CURLCOOKIE*" -mmin +$MINUTESTOKEEPFILES -delete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment