CRON AUTOLEARN SCRIPT
Again, Francisco wrote this script. It very useful. I'm only translating it to English.
nano /home/spamassassin/cron-autolearn.sh
=============================================================
#!/bin/bash
#1er argumento: domain without @
#2do argumento: submaildir, with . and without /
#3er argumento: database path, without /
#4er argumento: learning mode: SPAM/HAM
#5to argumento: MOVE/COPY
if [ "$1" = "" ]; then echo domain missing; exit; fi
if [ "$2" = "" ]; then echo submaildir missing; exit; fi
if [ "$3" = "" ]; then echo backup path missing; exit; fi
if [ "$4" = "" ]; then echo learning mode missing, SPAM/HAM; exit; fi
if [ "$5" = "" ]; then echo MOVE/COPY missing; exit; fi
if [ "$4" = "HAM" ]; then tipo="--ham"; fi
if [ "$4" = "SPAM" ]; then tipo="--spam"; fi
if [ "$5" = "MOVE" ]; then comando="mv"; fi
if [ "$5" = "COPY" ]; then comando="cp"; fi
if [ "$tipo" = "" ]; then echo misinserted arguments, read script comments; exit; fi
if [ "$comando" = "" ]; then echo missinserted arguments, read script comments; exit; fi
echo ====== Autolearn $(date +%d/%m/%y\ %H:%M:%S) $4
echo ===============================================================
for name in /home/vpopmail/domains/$1/{,[0-9]/}*/Maildir ; do
if [ "$(expr "$name" : ".*\(\[\).*")" = "[" ]; then continue; fi;
user=$(expr "$name" : ".*/\(.*\)/Maildir")
destino="$3/$(date +%Y-%b-%d-%M)-$4-$user@$1.Mails"
echo "-> $user@$1:";
cd $name/$2 2> /dev/null ; if [ "$?" = "1" ]; then echo Maildir $2 doesn't exist; continue; fi;
mkdir $destino
cd $name/$2/cur
if [ "$(ls -1 | grep -c "")" != "0" ]; then
sa-learn $tipo --no-sync $name/$2/cur/*;
$comando $name/$2/cur/* $destino;
fi
cd $name/$2/new
if [ "$(ls -1 | grep -c "")" != "0" ]; then
sa-learn $tipo --no-sync $name/$2/new/*;
$comando $name/$2/new/* $destino;
fi
cd $destino
if [ "$(ls -1 | grep -c "")" = "0" ]; then rm -r $destino; fi
echo "-----Done"
done;
echo ====== Finished $(date +%H:%M:%S)
echo ===============================================================
echo
=============================================================
chmod 750 /home/spamassassin/cron-autolearn.sh
mkdir /home/spamassassin/cron-compilation
crontab -e
-----------------------------------------------------
# CRON AUTOLEARN SPAM
10 05 */14 * * /home/spamassassin/Cron-Autolearn.sh innova-red.net .Spam /home/spamassassin/Compilado-Mails-Cron SPAM MOVE 2>&1 | mail -s "Script Autoaprender: Spam Innova-Red" operaciones@innova-red.net
20 05 */21 * * /home/spamassassin/Cron-Autolearn.sh innovat.org.ar .Spam /home/spamassassin/Compilado-Mails-Cron SPAM MOVE 2>&1 | mail -s "Script Autoaprender: Spam Innovat.org.ar" operaciones@innova-red.net
################################33
# CRON AUTOLEARN HAM
30 05 1 * * /home/spamassassin/cron-autolearn.sh DOMAIN.COM .Sent /home/spamassassin/cron-compilation HAM COPY 2>&1 | mail -s "Autolearn Script: Ham" POSTMASTER@DOMAIN.COM
##
-----------------------------------------------------
# CRON AUTOLEARN SPAM
10 05 */14 * * /home/spamassassin/cron-autolearn.sh DOMAIN.COM .Spam /home/spamassassin/cron-compilation SPAM MOVE 2>&1 | mail -s "Autolearn Script: Spam" postmaster@domain.com
##################################
You should check the size of those folders eventually.