Delete email over xdays old

IT_Architect

Verified User
Joined
Feb 27, 2006
Messages
1,088
I have basically 2 problems:
1. I want to delete email over xdays old automatically.
2. I noticed when a user has very few emails, no attachements, no trash, and no sent, the file that shows in /var/spool/virtual/domainname.com/emailuser might be huge. Why is that?
 
Possibly because the user isn't deleting emails after download. It's a text file so you can look at it and see what it contains.

Jeff
 
Thanks Jeff.

I don't know what the problem is. When I login SquirrelMail / Nutsmail, there is nowhere near that much info there anywhere in that account. That one account shows about 1.1 gig of space altogether. However, even running du -sk in both areas don't show anywhere near that. It has 1 domain and no db.

I guess I need to pull a little more hair.

Thanks!
 
Try a script like this to delete old stuff. Remove the -delete from the find lines when you test it though just to make sure you dont delete anything before you want to.

Put it in file on your server ahd chmod it 750
Then run ./name-of-file

Code:
#!/bin/sh

folder=/var/spool/virtual # set to folder to check
num_days_old="60" # set to number of days old


time=$(date '+%H:%M:%S %Z')

##########

if [ `id -u` != "0" ]; then
echo ""
echo "CRITICAL: $0 must be run as root only!"
echo ""
exit 1

else

for i in $folder/*.*; do

echo ""
time=$(date '+%H:%M:%S %Z')
echo "[$time] Changing directory to: $i"
echo ""
cd $i
sleep 1
time=$(date '+%H:%M:%S %Z')
echo -n "[$time] Found old file(s): "

if [ `uname -s` = "FreeBSD" ]; then
find . -maxdepth +1 -mtime +$num_days_old -delete
else
find . -maxdepth +1 -mtime $num_days_old -delete
fi

echo ""

done

time=$(date '+%H:%M:%S %Z')
echo "Completed at $time"
echo ""

fi
 
>Try a script like this to delete old stuff. Remove the -delete from the find lines when you test it though just to make sure you dont delete anything before you want to. Put it in file on your server ahd chmod it 750. Then run ./name-of-file<

THAT I will look at. I need to do something that works.

Thanks!
 
Back
Top