Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sendmail to retry after connection failure 1

Status
Not open for further replies.

rzs0502

IS-IT--Management
Nov 18, 2002
708
Hi,

I have several AIX servers using sendmail which forwards to a Smart Relay Server.
The relay server goes on the blink every now and then which causes 'failed to connect' errors and the mails remain in the mail queue.
Restarting the sendmail daemon then re-sends these mail.
Is there another way of ensuring that these mails are delievered without having to re-start?

Thanks


"If you always do what you've always done, you will always be where you've always been."
 
I don't know of a way, but you could possibly add a cron job to periodically check for sendmail (through a ps listing), and if it isn't present, start it without intervention from you. Something like:

ps -ef | grep sendmail | grep -v grep
if [ $? -gt 0 ]
then
<restart sendmail>
else
exit
fi

should suffice.
 
Quick response!
I was just thinking the same thing...
Thanks!!


&quot;If you always do what you've always done, you will always be where you've always been.&quot;
 
Thanks for the star! However, thinking again about this and considering it's AIX, you may want to take a look at the man page for inittab, particularly the respawn option. Good luck.
 
Thanks,
I've put this in the cron for now...

#!/usr/bin/ksh
#Checks for mails with connection failures and restarts sendmail if necessary

export MAILPID=`ps -ef|grep endmail | awk ' {print $2} '`
export FAILED=`mailq | grep "Connection refused" | wc -l`
export HOST=`uname -n`

if [ $FAILED -gt 0 ] ; then
kill -15 $MAILPID
/usr/sbin/sendmail -q30m
if [ $? -eq 0 ] ; then
echo "Sendmail has been restarted on $HOST" | mailx -s "Sendmail restarted" aixadmin
else
echo "Sendmail restart has failed on $HOST" | mailx -s "Sendmail restart failed!" aixadmin
fi
fi



&quot;If you always do what you've always done, you will always be where you've always been.&quot;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top