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
