Am 16.10.2012 15:20, schrieb James Day:
> I use the following to do just that. I'm sure there is a better way but I 
> fudged this together myself
> 
> Script 1:
> 
> #!/bin/bash
> 
> /usr/bin/mailq | /usr/bin/tail -n1 | /usr/bin/gawk '{print $5}' > 
> /etc/postfix/mailq_count
> 
> Script 2:
> 
> #!/bin/bash
> 
> mailq_count="/bin/cat /etc/postfix/mailq_count"
> 
> if [ `$mailq_count` -gt 50 ]; then echo "Mail count on Server is" 
> `$mailq_count`|/usr/sbin/sendmail -f r...@example.com repo...@example.com ; fi
> 
> 
> These run as cron jobs every few minutes.

thank you for that

i optimized this to one script without temp-file

mailq_count=`expr $mailq_count + 0`
this makes sure that we have a number if queue is empty
otherwise: /usr/local/bin/watch-queue.sh: line 4: [: -gt: unary operator 
expected
_________________

#!/bin/bash
mailq_count=`/usr/bin/mailq | /usr/bin/tail -n1 | /usr/bin/gawk '{print $5}'`
mailq_count=`expr $mailq_count + 0`
if [ $mailq_count -gt 50 ]; then
 echo "Mail count on Server is $mailq_count"
fi

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to