Friday 9 December 2011

Script to check the qmail queue

Script to check the email available in the qmail queue.
---------------------------------------------------------------------------

Use this script to find the emails available in the qmail queue.


#!/bin/bash
mails=`/var/qmail/bin/qmail-qstat |grep "messages in queue:"|awk '{print $4}'`
if [ $mails -gt 200 ]; then
SUBJECT="Please check mail queue in RM7"
EMAIL="USER@domain.com"
MESSAGE="/tmp/message.txt"
echo "Please Check mail queue in RM7..It's more than 750" > $MESSAGE
nomail=`/var/qmail/bin/qmail-qstat`
nom=`/var/qmail/bin/qmHandle -s`
echo $nomail >>$MESSAGE
echo $nom >>$MESSAGE
mail -s "$SUBJECT" "$EMAIL" < $MESSAGE
fi

2 comments:

Anonymous said...

Thank you,
very usefull ...

Dhanasekaran N said...

Thank you for your comment :)

We always welcome your comments to improve our blog. So, Please keep on visiting our blog and provide your valuable suggestions.