Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Qmail: users

Script to force qmail to process the outbound queue

 

 

Qmail users RSS feed   Index | Next | Previous | View Threaded


victor_volpe at bol

Nov 4, 2007, 3:41 PM

Post #1 of 6 (1604 views)
Permalink
Script to force qmail to process the outbound queue

Hello,

If you have an internet outage or DNS problems, the qmail's outbound queue
will start to fill up. This script force it to process immediately:

#!/bin/sh

#
# Description: Bash Script to force qmail to process the outbound queue
# Compatibility: works fine with qmail 1.03 + daemontools 0.76
# Tip Source: http://www.fileformat.info/tip/linux/qmailnow.htm
# Author: Victor (victor_volpe [at] bol)
# Date: Sun Nov 4 22:16:42 BRST 2007
#

QUEUED=`/var/qmail/bin/qmail-qstat | grep 'messages in queue:' |
cut -c20-20`
PID=`ps ax | grep qmail-send | grep -v grep | grep -v supervise | awk
'{print $1}'`

if [ "$QUEUED" = 0 ]; then
echo No queued messages to process!
exit 1
fi

echo Processing messages on queue
echo ...
/var/qmail/bin/qmail-tcpok
/bin/kill -s ALRM "$PID"
echo Done!

- EOF -

Can get too the source by access: http://72.20.5.66/queuenow.txt

Thank you.


kyle-qmail at memoryhole

Nov 4, 2007, 7:23 PM

Post #2 of 6 (1507 views)
Permalink
Re: Script to force qmail to process the outbound queue [In reply to]

On Sunday, November 4 at 09:41 PM, quoth Victor:
> If you have an internet outage or DNS problems, the qmail's outbound
> queue will start to fill up. This script force it to process
> immediately:

That's probably a bad idea. For one thing, you have a race condition
with the use of the $PID variable; and using that is really *really*
unnecessary if you're using daemontools (i.e. supervise). All you need
to do is use the two commands from qmailctl.sh (which is in the LWQ):

/var/qmail/bin/qmail-tcpok
svc -a /service/qmail-send

~Kyle
--
A wise man changes his mind, a fool never.
-- Spanish proverb


jms1 at jms1

Nov 4, 2007, 7:59 PM

Post #3 of 6 (1501 views)
Permalink
Re: Script to force qmail to process the outbound queue [In reply to]

On 2007-11-04, at 1841, Victor wrote:
>
> If you have an internet outage or DNS problems, the qmail's outbound
> queue will start to fill up. This script force it to process
> immediately:

what's wrong with "svc -a /service/qmail-send" ?

----------------------------------------------------------------
| John M. Simpson --- KG4ZOW --- Programmer At Large |
| http://www.jms1.net/ <jms1 [at] jms1> |
----------------------------------------------------------------
| http://video.google.com/videoplay?docid=-1656880303867390173 |
----------------------------------------------------------------


kyle-qmail at memoryhole

Nov 4, 2007, 8:47 PM

Post #4 of 6 (1501 views)
Permalink
Re: Script to force qmail to process the outbound queue [In reply to]

On Sunday, November 4 at 10:59 PM, quoth John Simpson:
> On 2007-11-04, at 1841, Victor wrote:
>>
>> If you have an internet outage or DNS problems, the qmail's outbound queue
>> will start to fill up. This script force it to process immediately:
>
> what's wrong with "svc -a /service/qmail-send" ?

Unless you run qmail-tcpok first, qmail-remote will still cache time'd
out addresses to avoid getting hung up. Thus, domains qmail had
already discovered were offline won't be retried for another hour (as
described in the qmail-tcpto man page).

~Kyle
--
I'm as pure as the driven slush.
-- Tallulah Bankhead


jms1 at jms1

Nov 5, 2007, 8:29 AM

Post #5 of 6 (1507 views)
Permalink
Re: Script to force qmail to process the outbound queue [In reply to]

On 2007-11-04, at 2347, Kyle Wheeler wrote:
> On Sunday, November 4 at 10:59 PM, quoth John Simpson:
>> On 2007-11-04, at 1841, Victor wrote:
>>>
>>> If you have an internet outage or DNS problems, the qmail's
>>> outbound queue will start to fill up. This script force it to
>>> process immediately:
>>
>> what's wrong with "svc -a /service/qmail-send" ?
>
> Unless you run qmail-tcpok first, qmail-remote will still cache
> time'd out addresses to avoid getting hung up. Thus, domains qmail
> had already discovered were offline won't be retried for another
> hour (as described in the qmail-tcpto man page).

i dunno about you, but i see that as a good thing... if qmail already
knows that a given IP address is non-responsive, i'd rather see it
retry deliveries to the other IPs first anyway.

of course, that's my background showing through again. i'm used to
thinking in terms of ISP servers, where the tcpto list might have
hundreds of entries at any time. for a small server, what you're
saying probably makes a lot of sense- i'm just not used to thinking on
that small scale.

for an ISP server, i think it makes more sense to just run "svc -a" by
itself first, and if that doesn't "get it" (i.e. if there's a specific
message that you're trying to move along) then clear the list and try
the "svc -a" command again.

it's like i've said before, it all comes down to UNDERSTANDING- how
qmail works, what each program involved does, and what you actually
need on your own server.

----------------------------------------------------------------
| John M. Simpson --- KG4ZOW --- Programmer At Large |
| http://www.jms1.net/ <jms1 [at] jms1> |
----------------------------------------------------------------
| http://video.google.com/videoplay?docid=-1656880303867390173 |
----------------------------------------------------------------


kyle-qmail at memoryhole

Nov 5, 2007, 10:22 AM

Post #6 of 6 (1505 views)
Permalink
Re: Script to force qmail to process the outbound queue [In reply to]

On Monday, November 5 at 11:29 AM, quoth John Simpson:
> On 2007-11-04, at 2347, Kyle Wheeler wrote:
>> On Sunday, November 4 at 10:59 PM, quoth John Simpson:
>>> On 2007-11-04, at 1841, Victor wrote:
>>>>
>>>> If you have an internet outage or DNS problems, the qmail's outbound
>>>> queue will start to fill up. This script force it to process immediately:
>>>
>>> what's wrong with "svc -a /service/qmail-send" ?
>>
>> Unless you run qmail-tcpok first, qmail-remote will still cache time'd out
>> addresses to avoid getting hung up. Thus, domains qmail had already
>> discovered were offline won't be retried for another hour (as described in
>> the qmail-tcpto man page).
>
> i dunno about you, but i see that as a good thing... if qmail already knows
> that a given IP address is non-responsive, i'd rather see it retry
> deliveries to the other IPs first anyway.

No, it's not a good thing. Imagine this: there's an internet outage
(as the OP suggests). Qmail attempts to send a message, fetches the IP
address from your locally-installed djbdns cache, and attempts a
connection. Since your internet connection is down, the connection
times out, and qmail thinks that that particular host is offline. In
fact, EVERY IP address that it tries turns out to be non-responsive.
They all get added to the internal list of non-responsive IP
addresses. You then realize that the network is down and that your
queue has gotten enormous. You fix your network connection, and you'd
like qmail to start using it right away.

Unfortunately, "svc -a /service/qmail-send" won't help. Qmail will
stubbornly refuse to attempt to send any currently queued messages for
about an hour.

> for an ISP server, i think it makes more sense to just run "svc -a"
> by itself first, and if that doesn't "get it" (i.e. if there's a
> specific message that you're trying to move along) then clear the
> list and try the "svc -a" command again.

I think it depends on *WHY* you're running "svc -a" rather than who
you happen to be. If the reason you're running it is because your
internet connection has been down for a while and you want to get
deliveries going (e.g. to clear out the queue and tell people that
things are now operating normally), then clearing out the tcpto list
is probably smart. The longer your connection has been offline, the
less likely any of the entries in that list are likely to be useful
and/or valid, and the more of a backlog of undelivered messages you've
built up.

Put another way, why assume that the entries in the tcpto list are
correct if your network has been down for a while? The only reason I
can think of for sending qmail-send a SIGALRM without using
qmail-tcpok is if I have a bunch of mails ready for local delivery
that have stalled for some reason (e.g. a bad script) and I just fixed
the script that was the problem. The fact that you're an ISP rather
than a corporate mail server or a non-profit listserv or a vanity
domain doesn't have any bearing on whether to use qmail-tcpok, as far
as I can tell.

> it's like i've said before, it all comes down to UNDERSTANDING- how
> qmail works, what each program involved does, and what you actually
> need on your own server.

HEH - doesn't everything? :)

~Kyle
--
Being powerful is like being a lady. If you have to tell people you
are, you aren't.
-- Margaret Thatcher

Qmail users RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.