#!/bin/bash

CLEAN_ROOT=/jdmail
export CLEAN_ROOT
#更改清理多久之前的邮件，默认为180，半年
cleantime=180


domains=`ls $CLEAN_ROOT/accounts| grep -v .xml$|grep -v .xml.bk$|grep -v root$`
cd $CLEAN_ROOT/accounts && for domain in $domains
do
	cd $domain && for user in `ls -1 |grep -v .xml$|grep -v .xml.bk$`
		do 
			echo $user >> $CLEAN_ROOT/logs/clean/clean-`date +20%y-%m-%d`.log
			find $user/Maildir -name "*" -type f -mtime +$cleantime -exec ls {} \; >> $CLEAN_ROOT/logs/clean/clean-`date +20%y-%m-%d`.log -exec rm {} \;	 
		done && cd ..
done

