Remove blobs by size and modification time
Inspired by an idea by @joeyh, I have written a thin wrapper around find(1)
from GNU findutils to remove blobs based on their sizes and modification times, suitable to be run as a cron.daily
job.
What the script does is basically several iterations of
find "$BLOBS_DIR" -type f -size "+$SIZE" -mtime "+$DAYS" -print0 \
| xargs -r0 rm -f # substitute “rm -f” with “ls -l”
# to see the blobs without removing them
The unmodified script will remove these blobs:
size > 5120k and age > 1 day,
size > 4096k and age > 7 days,
size > 2048k and age > 28 days,
size > 1024k and age > 91 days,
size > 512k and age > 365 days,
and empty blobs of any age.
Use at your own discretion.
See also: %48ulqS…