Cron job for SpamAssassin

I am trying to schedule an automatice update of SpamAssassins rules using the following command:

Code:
sa-update

When I run the command manually it runs fine.

But when I put:
Code:
00      4       *       *       *       root    sa-update

in my /etc/crontab and I receive the email alert it always says:
Code:
sa-update: not found

I have also tried the following in cron:
Code:
00      4       *       *       *       root    sa-update -v
00      4       *       *       *       root    sa-update -D

but I still get the same output. Does anyone know how to successfully schedule this kind of update with SpamAssassin?

Thanks! ;)
 
Oh dear that was a noob mistake! Adding the full path did the trick.

From what I understand I need to reload spamd after sa-update has run. I tried:
Code:
00      4       *       *       *       root   /usr/local/bin/sa-update -v && /usr/local/etc/rc.d/sa-spamd restart

This still ran sa-update succesfully but didn't restart the spamd service. Have I got the correct syntax?
 
If you want to do more than one thing in a cronjob, then write a script that does all the steps, and just point cron at that script.
 
Aaaah got it now I think. I created a file in /root called "reload" and put the commands in there. That seemed to do the trick with cron now!
 
You're advised to leave the system crontab (/etc/crontab) well alone, because it can be updated/overwritten when upgrading the base system. Use the root user's crontab (crontab -e as the root user).
 
Thanks DD, I will be sure to change it on the weekend.

In the mean time, now that I have scheduled my cron job to run the script that runs the sa-update command and restart the spamd service I am getting the following error:
Code:
error: gpg required but not found!
Stopping spamd.
Waiting for PIDS: 61242.
Starting spamd.

I tried putting gpg in the PATH variable:
Code:
PATH=/etc:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin/gpg

but this didn't make a difference. When I run the script as root it runs perfectly so this error only occurs when cron runs it, why is this?
 
Don't put commands in the PATH, but the directory containing the command (i.e. /usr/local/bin and /usr/local/sbin are usually needed to be added to cron's PATH).
 
Back
Top