Mail Queue monitor?

mikea mikea at
Wed Aug 16 17:29:58 IST 2006

On Wed, Aug 16, 2006 at 11:22:27AM -0400, Rob Morin wrote:
> Is ther a script i can use to monitor teh mail queue on my postfix 
> system, and i fits over a certain amount email me or page me....
> So every 5  or 10 mins this script would run and if the email in the 
> queue is over 100 send an email to a pager...
> I guess i would have to run this command from an external machine via 
> ssh as i figure if i run it locally and the queue is big i would never 
> get the email?

: #! /bin/sh
: #
: #   mq - display inbound and outbound mail queue once
: #
: echo inbound queue
: sudo sendmail -v -bp -OQueueDirectory=/var/spool/
: echo ========================
: echo outbound queue
: sudo mailq -v

You'll get lots of entries like this: 

k7BIfApo069090   470102 Fri Aug 11 13:41 <sender at sender.domain
                 (Deferred: Operation timed out with rcpt.domain)
                                         <recipient at rcpt.domain)

Egrepping out the timestamp parts and piping them to "wc -l" seems to
a cheap way to get a count of entries in each queue.

Mike Andrews, W5EGO
mikea at
Tired old sysadmin 

More information about the MailScanner mailing list