#!/bin/bash # bin mail-prune -ci "-vD" -- \ # mail-prune -- remove old mail after a it was filed a certain time ago revision='$Revision: 1.9 $'; version(){ cat < This is free software; see the GNU General Public License version 2 or later for copying conditions. There is NO warranty. VRS false; } help() { cat <&2;} yyyy_mm=`date +%Y-%m` PRUNE_LOG="log/prune.$yyyy_mm" CONFIG="$HOME/.procmailrc.include" errno=0; pgm=mail-prune one="DHV" while getopts "S:$one" option;do case "$option" in H) help;; V) version $revision;; S) set $OPTARG;; D) debug=/bin/echo;; #q) quiet=:;; \?) false;; *) false;; esac|| exit; done shift $(($OPTIND-1)); . "$CONFIG"|| exit; set -- PRUNE_WEEK_OLD 7 PRUNE_TWO_WEEKS_OLD 14 PRUNE_MONTH_OLD 30 PRUNE_TWO_MONTHS_OLD 60 "$@" [ "$MAILDIR" ]|| error "MAILDIR variable is null"|| exit; cd "$MAILDIR"|| exit; [ "$PRUNE_LOG" ]|| error "PRUNE_LOG variable is null"|| exit; exec 4>>"$PRUNE_LOG"|| exit; { while [ $# -gt 1 ]; do [ "$2" -gt 0 ]&& for folder in ${!1}; do [ -d "$folder/cur" ]&& find "$folder/cur" -type f -mtime +$2| xargs -r $debug rm -v -f; done shift 2 done; } | Logger >&4;