#!/bin/bash cleanup() { local data_path="$1" # full path to data directory of wiki local retention_days="$2" # number of days after which old files are to be removed # purge files older than ${retention_days} days from attic and media_attic (old revisions) find "${data_path}"/{media_,}attic/ -type f -not -name _dummy -mtime +${retention_days} -delete # remove stale lock files (files which are 1-2 days old) find "${data_path}"/locks/ -name '*.lock' -type f -mtime +1 -delete # remove files older than ${retention_days} days from the cache find "${data_path}"/cache/?/ -type f -not -name _dummy -mtime +${retention_days} -delete # remove empty directories find "${data_path}"/{attic,cache,index,locks,media,media_attic,media_meta,meta,pages,tmp}/ -mindepth 1 -type d -empty -delete } # cleanup DokuWiki installations (path to datadir, number of days) # some examples: if [ $# -eq 1 ]; then REP_WIKI="$1/data" if [ -d ${REP_WIKI} ]; then cleanup ${REP_WIKI} 30 else printf "\n\t>>> Répertoire ${REP_WIKI} inexistant\n\n" exit 1 fi else printf "\n\t>>> Passer le répertoire du Dokuwiki en paramètre\n\n" exit 1 fi