#!/bin/bash cleanup() { # $1 ... full path to data directory of wiki # $2 ... number of days after which old files are to be removed # purge files older than $2 days from the attic (old revisions) find "$1"/attic/ -type f -mtime +$2 -print0 | xargs -0r rm -f # remove stale lock files (files which are 1-2 days old) find "$1"/locks/ -name '*.lock' -type f -mtime +1 -print0 | xargs -0r rm -f # remove empty directories find "$1"/{attic,cache,index,locks,media,meta,pages,tmp}/ \ -mindepth 1 -type d -empty -print0 | xargs -0r rmdir # remove files older than $2 days from the cache find "$1"/cache/?/ -type f -mtime +$2 -print0 | xargs -0r rm -f }