Looking for script that empty spambox folder!

wimp

Well-Known Member
Jul 13, 2002
301
0
166
hi all,
spamassassin is greate. However most customer don never empty there spambox so a lot of space will be used. Is there any script that can empty the spambox afther x days automatically?


Thanks a lot
 

AndyMurray

Registered
Jun 12, 2004
4
0
151
I once made a script which trims the spambox to the last 30 days only. PM me if you want the code as I don't have it to hand.
 

electric

Well-Known Member
Nov 5, 2001
780
8
318
payne said:
If you find it, can you post it here? So we don't all pester you individually.
Yes, thanks!
 

daniele81

Member
Aug 27, 2003
19
0
151
Empty all spamboxes (very simple solution)

I empty all spamboxes every 2 hours with this command on crontab:

find /usr/home -name "spam" -group mail -exec truncate -s 0 {} \;
This command find all files named "spam" with group "mail" on /usr/home (my homes directory), then truncate it at zero byte.

The command "truncate" works fine on FreeBSD (i don't know on Linux).
It's brutal, but works.
 

chirpy

Well-Known Member
Verifed Vendor
Jun 15, 2002
13,466
30
473
Go on, have a guess
There's unlikely to be a truncate command on Linux. However, you could simply replace the truncate function with cat /dev/null > filename

That said, user education is probably better :)
 

payne

Well-Known Member
May 31, 2003
103
0
166
Seattle
I think we'll run this weekly. That way, they have a spam box, but it doesn't get out of hand, especially for those folks who never check it (it is on or off for the entire account).
 

payne

Well-Known Member
May 31, 2003
103
0
166
Seattle
so, I can't get it to work. I'm trying:

Code:
find /home -name "spam" -group mail -exec cat /dev/null > {} \;
and it isn't working. I've tried them separately, the find works and the cat /dev/null works when I replace the {} with a filename... they just don't work together like this. What am I missing?
 

vla

Member
Jun 19, 2004
17
0
151
I use the following on several linux boxes


$ find /home -name "spam" -group mail -follow | xargs -i -t rm -f {}
 

ispro

Well-Known Member
Verifed Vendor
Apr 8, 2004
628
2
168
Use the following code:
find /home*/*/mail/ -name "spam" -group mail -size +1024k | xargs -i rm -f {}
We are using this code and it works well. It remove the SpamBox only if the inbox over 1 Mb.
 

dprophit

Member
Apr 1, 2002
15
0
301
Useful! Added to cron.weekly

Thanks guys! I added find /home*/*/mail/ -name "spam" -group mail -size +1024k | xargs -i rm -f {} to the cron
 

bjarte

Member
Dec 8, 2005
17
0
151
find /home/*/mail/ -name "spam" -size +1024k | xargs -i sh -c "cat /dev/null > {}"
 

rec9140

Member
Jun 7, 2007
6
0
151
find /home/*/mail/ -name "spam" -size +1024k | xargs -i sh -c "cat /dev/null > {}"
I am trying to add this to a site to test it out, but when I add it to the crontab using standard mode it cuts it off at

Code:
find /home/*/mail/
And when I add it via the unix mode, it doesn't even add it to the crontab.

Any hints?

cPanel Build 10.9.1-STABLE 14304
Theme cPanel X v2.6.0