postfix/check_mail_queue
Peter Varkoly 96c09fe6a3 - New file check_mail_queue. This script checks if there are some
mails in the queue and starts postfix if necessary. After delivering
  the mails postfix will be stoped.

OBS-URL: https://build.opensuse.org/package/show/server:mail/postfix?expand=0&rev=38
2010-04-07 12:40:58 +00:00

25 lines
477 B
Bash

#!/bin/bash
nm()
{
NM=$( /usr/bin/mailq 2> /dev/null | tail -1 | /usr/bin/gawk '{ print $5 }' )
if [ "$NM" ]
then
return 0
else
return 1
fi
}
test -e /var/run/check_mail_queue.pid && exit;
echo $$ > /var/run/check_mail_queue.pid
while( nm )
do
/etc/init.d/postfix status || /etc/init.d/postfix start
sleep 10
/usr/sbin/postfix flush
done
/etc/init.d/postfix status && /etc/init.d/postfix stop
rm /var/run/check_mail_queue.pid