On Thu, 2014-10-09 at 11:50 +0700, Olivier Nicole wrote: > Hi, > > > /usr/local/bin/sa-update && /usr/local/bin/sa-compile && > > /usr/local/etc/rc.d/sa-spamd restart > > > > the only time spamd would restart is if sa-update AND sa-compile were > > successfully completed, correct? > Yes, that's correct.
> Sorry for jumping in the conversation... I have solved that issue by > calling sa-update from a script (perl) and I do a spamassassin -lint > before ever trying to restart spamd (or amavisd in my case), so I am > sure that I will only restart on something clean. > > That way, I can also update some rules that are not on sa-update. > I do something similar on my SA rules development system (I also have SA installed on this laptop but it is normally not running, which has the side effect of disabling the standard Fedora sa-update cron job because this won't run sa-update if it can't find the spamd daemon). My more complex equivalent is a bash script rather than Perl which starts and stops SA after a successful update in order to check that all is in order. This is it. I think the use of the case...esac construct makes it easier to read: =========================================================================== #!/bin/bash # # Update the Spamassassin rules # sau=/usr/bin/sa-update if [ -x $sau ] then $sau err=$? case $err in 0) echo "Spamassassin rules update completed."; service spamassassin restart; service spamassassin stop; echo "Spamassassin restarted and then stopped." ;; 1) echo "No Spamassassin rule updates available.";; 2) echo "Spamassassin rules updates available"; echo "Site pre files lint check failed."; echo "Fix the files and try again.";; *) echo "Spamassassin rules update failed: error=$err" esac else echo "Error: $sau does not exist" exit 0 fi =========================================================================== > And in any case, send myself an email if something went wrong. > I get the mail 'for free' because I run logwatch, which picks up anything logged by crond (i.e. anything sent to stdout and stderr by a cron job) and mails it to root and, of course, I set up the mail aliases so mail sent to root is redirected to my usual login. > Being executed only once a day, the extra load of a Perl script is > neglectible. > Agreed. Martin