#!/bin/sh # # expunge-mailboxes # John Simpson 2003-05-16 (or thereabouts) # # delete any messages in vpopmail mailboxes which are marked for deletion # and which have not been touched for a week # ############################################################################### # # Copyright (C) 2003,2008 John Simpson. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License, version 3, as # published by the Free Software Foundation. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # ############################################################################### # default to 7 days if no number is listed on the command line DAYS=${1:-7} # the GNU version of "find" has this really nice "-delete" option, which # saves a LOT of fork()/exec() activity... find ~vpopmail/domains -ctime +$DAYS \( -regex '.*/Maildir/cur/.*:2,.*T.*' \ -o -regex '.*/Maildir/.*/cur/.*:2,.*T.*' \) -print -delete # if your "find" doesn't have a "-delete" option, do it the old way #find ~vpopmail/domains -ctime +$DAYS \( -regex '.*/Maildir/cur/.*:2,.*T.*' \ # -o -regex '.*/Maildir/.*/cur/.*:2,.*T.*' \) -print \ # -exec rm "{}" \;