Auto clean up large spamassassin log files

wkdwich

Well-Known Member
Apr 11, 2005
105
0
166
I have over 300 users on this server and many get large volumes of mail daily.. the spamassasin logs get quite large on a regular basis..

Is there anyone out there that can help me create a script to put to cron.monthly to clear out these logs?

thanks
 

wkdwich

Well-Known Member
Apr 11, 2005
105
0
166
Manuel, thanks for the response.. can you be a little more specific here?? I assume I need to do something with the logrotate.conf .. below:

# system-specific logs may be also be configured here.

But I havent a clue where to go from there..

Since there is one set of SA files for each domain:

[email protected] [/etc]# ls -la /home/wkdwich/.spamassassin
-rw------- 1 wkdwich wkdwich 2523136 Sep 19 14:54 auto-whitelist
-rw------- 1 wkdwich wkdwich 93240 Sep 19 14:54 bayes_journal
-rw------- 1 wkdwich wkdwich 1318912 Sep 19 14:54 bayes_seen
-rw------- 1 wkdwich wkdwich 10473472 Sep 19 14:54 bayes_toks
-rw-r--r-- 1 wkdwich wkdwich 1228 Jun 25 2005 user_prefs


[email protected] [/etc]# ls -la /home/davyd/.spamassassin
total 1284
drwx------ 2 davyd davyd 4096 Sep 19 09:06 ./
drwx--x--x 13 davyd davyd 4096 Sep 19 09:06 ../
-rw------- 1 davyd davyd 167936 Sep 19 09:06 auto-whitelist
-rw------- 1 davyd davyd 83968 Sep 19 09:06 bayes_seen
-rw------- 1 davyd davyd 1291264 Sep 19 09:06 bayes_toks
-rw-r--r-- 1 davyd davyd 1230 Apr 23 2005 user_prefs


you can see how these files are quite large.. the ones for wkdwich domain have been cleared out within the last 30 days

I would like to rotate them or just clear them out would be sufficent.
 
Last edited:

MRiscado

Member
Feb 22, 2004
22
0
151
wkdwich said:
I have over 300 users on this server and many get large volumes of mail daily.. the spamassasin logs get quite large on a regular basis..

Is there anyone out there that can help me create a script to put to cron.monthly to clear out these logs?

thanks

Hi wkdwich,
Any solution to clear all these spamassasin logs by cron?
Thanks
 

wkdwich

Well-Known Member
Apr 11, 2005
105
0
166
no, it's probably a simple solution using one of the existing log rotate jobs as a base, but I have been traveling, the desk is piled way too high and I just don't have the skills myself to go down that road..
 

beehave

Well-Known Member
Jun 26, 2005
104
0
166
This will empty every file in each user's .spamassassin folder

#!/bin/bash

clear

echo
echo "This will delete all Spamassassin Logs!!!"
echo

for user in `ls /home`; do
if [ -d /home/$user/.spamassassin ]; then
echo "Processing $user......."
for file in `ls /home/$user/.spamassassin`; do
cat < /dev/null > /home/$user/.spamassassin/$file
done
fi
sleep 1
done

exit
Is that what you were wanting? Are all the files log files?
 

wkdwich

Well-Known Member
Apr 11, 2005
105
0
166
hum, that looks like it might do the trick.. what effect will the echo have if it is run by cron?? I assume that will be in the email notice I will get after the cron runs??

thanks
 

beehave

Well-Known Member
Jun 26, 2005
104
0
166
wkdwich said:
hum, that looks like it might do the trick.. what effect will the echo have if it is run by cron?? I assume that will be in the email notice I will get after the cron runs??

thanks
It would have no effect. You can remove those lines if you want.

What about the files. Are they all log files? No problems with emptying them?
 

Starfinder

Registered
Aug 17, 2005
1
0
151
beehave said:
It would have no effect. You can remove those lines if you want.

What about the files. Are they all log files? No problems with emptying them?
You may want to think twice before running this script. As beehave rightly asks, they are not logfiles.

'user_prefs' is the user preferences, 'auto-whitelist contains addresses which have been auto-added to the whitelist. The rest, I think, are system files used when deciding whether a messages is spam or not.

I am no spamassassin expert, but i believe this script would just revert the user's spamassassin settings to the server default, and wipe out the accumulated 'learning' data.