You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@spamassassin.apache.org by Jay Levitt <ja...@shopwatch.org> on 2004/05/07 14:37:11 UTC

Semi-OT: Truncated output from daily bayes cron job?

I'm running Mandrake 9.0, with SA 2.63 running in MIMEDefang 2.39.  I 
run a daily cron job under the defang user:

15 5 * * *      /usr/local/bin/daily_bayes &2>&1

This tells sa-learn to treat messages in my Spam folder as spam, and Ham 
folder as ham, thus allowing me to learn messages simply by dragging 
them to the right folder in my IMAP client, and providing a 
simpler/safer form of auto-learning.  I think I got the script (or at 
least the idea) from someone here.  The complete script is below.

The weird thing: Some days, the output of the cron job is truncated 
right after "Beginning daily_bayes at (date)".  Some days it's not.  
This is the ONLY cron job that has this problem!  As you can see, I 
modified it to run itself while tee'ing the output to a log file, and 
that log file is always complete.  I can't understand how that could be 
the case.. unless sa-learn is somehow sometimes outputting some control 
character that tells cron "output finished" but doesn't affect the tee 
pipe?  I'm kinda stumped.

Anyone have any ideas?

----------------

#!/bin/bash
LOGFILE=daily_bayes.out

if [ "$DB_LOGGING" != "true" ] ; then
    DB_LOGGING="true" ; export DB_LOGGING ;
    exec $0 | tee -a $LOGFILE 2>&1
    exit 0
fi

echo
echo Beginning daily_bayes at `date`
echo

/usr/bin/sa-learn --force-expire
if [ $? -ne 0 ]; then
    echo force_expire bad exit status $?
fi

/usr/bin/sa-learn  --spam --dir /mail/spool/imap/user/jay/Spam
if [ $? -ne 0 ]; then
    echo Spam-dir bad exit status $?
fi

/usr/bin/sa-learn  --ham --dir /mail/spool/imap/user/jay/Spam/Ham
if [ $? -ne 0 ]; then
    echo Ham-dir bad exit status $?
fi

echo
echo Completing daily_bayes at `date`
echo