I created a script to auto learn spam every hour, I want the script to auto start spamd if its not running.
Auto start line is:
ps -auxwww | grep spamd | grep -v grep >> /dev/null || '/usr/bin/ spamd -d --syslog=/var/log/spamd.log &'

Error I get when running and spamd is off is:
/usr/bin/learn_spam: line 7: /usr/bin/spamd -d --syslog=/var/log/ spamd.log &: No such file or directory

line look bad?

Other versions I tried:

ps -auxwww | grep spamd | grep -v grep >> /dev/null || 'spamd -d -- syslog=/var/log/spamd.log &' ps -auxwww | grep spamd | grep -v grep >> /dev/null || './usr/bin/ spamd -d --syslog=/var/log/spamd.log &'

Stop torturing yourself - just use monit:

http://www.tildeslash.com/monit/

It's insanely configurable and can monitor nearly anything, and stop/restart it if it's not responding. For instance, here's my entry from Monit's config file for SpamAssassin:

check process spamd with pidfile /tmp/spamd.pid
start program = "/etc/rc.d/init.d/spamassassin start"
stop  program = "/etc/rc.d/init.d/spamassassin stop"
if failed unixsocket /var/run/spamd.sock then restart

(I disabled network access to spamd, otherwise I'd be testing connecting via its port as well.)

Reply via email to