Pantek Library
Hosting Provided By
CybrHost
High Speed Hosting

Re: spamd keeps running at 99% CPU until i kill the process

From: John D. Hardin <jhardin(at)impsec.org>
Date: Thu Aug 30 2007 - 09:37:55 EDT


On Thu, 30 Aug 2007, Richard Hobbs wrote:

> ======================================================================
> echo "Updating rules..." && /usr/bin/sa-update && echo "Done, now
> checking config syntax..." && spamassassin --lint && echo "Done, now
> restarting spamd..." && /etc/init.d/spamassassin restart && echo "Done"
> ======================================================================
>
> However, if there are no updates (and sa-update exits with an exit code
> of 1) i would like to print "No updates, exiting" and then exit.
>
> So i modified it to become this:
>
> ======================================================================
> echo "Updating rules..." && /usr/bin/sa-update && echo "Done, now
> checking config syntax..." || echo "No updates, exiting"; exit &&
> spamassassin --lint && echo "Done, now restarting spamd..." &&
> /etc/init.d/spamassassin restart && echo "Done"
> ======================================================================
>
> However, whether there are updates or not, the script still exits - do
> you know which syntax i need to use here (i'm using bash, btw).

I'd recommend rewriting that to use if ... then ... else ... fi syntax. Pasting stuff together with && and || is only manageable when the logic is simple and straightforward.

Perhaps (off the top of my head):

echo "Updating rules..."

if /usr/bin/sa-update
then

	echo "Done, now checking config syntax..."
	if spamassassin --lint
	then
		echo "Syntax OK, now restarting spamd..."
		/etc/init.d/spamassassin restart
		echo "Done"
	else
		echo "Syntax error in update, please manually review!"
	fi
else
	echo "No updates, exiting."

fi  
--
 John Hardin KA7OHZ                    
http://www.impsec.org/~jhardin/
 jhardin@impsec.org    FALaholic #11174     pgpk -a jhardin@impsec.org
 key: 0xB8732E79 -- 2D8C 34F4 6411 F507 136C  AF76 D822 E6E6 B873 2E79
-----------------------------------------------------------------------
  There is no doubt in my mind that millions of lives could have been
  saved if the people were not "brainwashed" about gun ownership and
  had been well armed. ... Gun haters always want to forget the Warsaw
  Ghetto uprising, which is a perfect example of how a ragtag,
  half-starved group of Jews took 10 handguns and made asses out of
  the Nazis.                        -- Theodore Haas, Dachau Survivor
-----------------------------------------------------------------------
 20 days until Talk Like a Pirate day
Received on Thu Aug 30 09:40:12 2007

This archive was generated by hypermail 2.1.8 : Fri Oct 26 2007 - 03:21:42 EDT


Contact Us  Legal Notices  Order Services Online 
Pantek Home  Privacy Policy  IT news  Site Map  Pantek Library