#!/bin/bash
#< Script to remove old quarantine and virus mails, plus cocoon logs from web/mail servers
ECHO="/bin/echo"
FIND="/usr/bin/find"
RM="/bin/rm"
SLEEP="/usr/bin/sleep"
TR="/usr/bin/tr"
XARGS="/usr/bin/xargs"
TARGET[0]="/www/webapps/cocoon/WEB-INF/logs"
TARGET[1]="/var/amavis/quarantine"
TARGET[2]="/var/amavis/virusmails"
${ECHO} "WARNING: This script will remove all files in the following directories"
${ECHO} "$( ${ECHO} ${TARGET[@]} | ${TR} ' ' '\n' )"
${ECHO} "that haven't been modified for more than 7 days"
${ECHO} "Sleeping for 5 seconds - CTRL-C if you need to!"
${SLEEP} 5
for DIRECTORY in ${TARGET[@]}; do
${ECHO} "--> Performing prune in ${DIRECTORY}"
${FIND} ${DIRECTORY} -type f -mtime +7 | ${XARGS} ${RM} 2>/dev/null
${ECHO} "--> Prune in ${DIRECTORY} complete"
done
exit 0