Home Forums OS X Server and Client Discussion Questions and Answers cron job not executing in MACOSXS 10.3

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #357195
    Bill Eccles
    Participant

    Gentleones,

    In OSXS 10.3, I’ve added one line to my /etc/crontab, below:

    [code:1:26fe26a6a9]0,15,30,45 * * * * root /usr/sbin/learnspam [/code:1:26fe26a6a9]

    (There are tabs between each of the items in the above table.)

    As you can see, the /etc/crontab file has kept its permissions and ownerships:

    [code:1:26fe26a6a9]-r–r–r– 1 root wheel 339 7 Jan 07:13 /etc/crontab [/code:1:26fe26a6a9]

    I know that it is still in working order because daily.out gets updated by /usr/sbin/periodic when it should.

    And you can see that the script being called has correct (as best I can tell–they match /usr/sbin/periodic) permissions, too:

    [code:1:26fe26a6a9]-r-xr-xr-x 1 root wheel 851 5 Jan 15:43 /usr/sbin/learnspam [/code:1:26fe26a6a9]

    (The script is at the bottom of this post.) Furthermore, I can execute the script manually with no errors with “sudo /usr/sbin/learnspam”.

    But the sa-learn.log file shows no activity (it’s there, owned by root, and reflects changes when I manually invoke learnspam), and indeed, none has occurred because, as reported by sa-learn, the spam builds up until I manually execute the learnspam script.

    Anyone got some clues on this one?

    Many thanks,
    Bill

    learnspam:

    [code:1:26fe26a6a9]#!/bin/sh –

    SPAM=/var/spool/imap/reportspam/*.
    HAM=/var/spool/imap/reportnotspam/*.
    LOGFILE=/var/log/sa-learn.log

    echo ‘ ‘ >> $LOGFILE
    echo "********************* Learnspam run starting " >> $LOGFILE
    date +%Y-%m-%d+%H:%M:%S >> $LOGFILE
    echo ‘ ‘ >> $LOGFILE
    echo ‘Learning as spam:’ >> $LOGFILE
    sa-learn –spam /var/spool/imap/user/reportspam/*. >> $LOGFILE 2>&1

    rm /var/spool/imap/user/reportspam/[0-9]*
    sudo -u cyrus /usr/bin/cyrus/bin/reconstruct user/reportspam

    echo ‘ ‘ >> $LOGFILE
    echo ‘Learning as ham:’ >> $LOGFILE

    sa-learn –ham /var/spool/imap/user/reportnotspam/*. >> $LOGFILE 2>&1

    rm /var/spool/imap/user/reportnotspam/[0-9]*
    sudo -u cyrus /usr/bin/cyrus/bin/reconstruct user/reportnotspam

    echo ‘ ‘ >> $LOGFILE
    echo ‘Script learnspam done.’ >> $LOGFILE

    # /usr/local/bin/sa-learn –rebuild -p /var/amavis/.spamassassin/user_prefs[/code:1:26fe26a6a9]

    #357298
    Anonymous
    Participant

    Try writing your cron entry like this:
    [code:1:5089f52247]
    */15 * * * * sh /usr/sbin/learnspam
    [/code:1:5089f52247]

    #357300
    Bill Eccles
    Participant

    I did as you suggested with no change to the operation (or lack thereof, really) in the cron jobs executed (or not).

    This one’s got me stumped.

    Many thanks!

    #357303
    Bill Eccles
    Participant

    If there’s not a trailing <CR> (or maybe it’s <CR><LF>… anyway…) at the end of the last line of the file, cron won’t read it.

    To make sure everything’s cool, I added a comment line to become the last line of the file.

    Yikes. That was tough!

    Thanks for thinking about it, all,
    Bill

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.

Comments are closed