texasweb
May 6 2006, 01:32 PM
I need help in writing a script. I want to run a script that runs the qstats command and takes the output from the command "messages in queue: 8"
and does 2 things .. send an email script to notify me and 2 run a cleanqueue script. I want these command to kick off when the queue gets larger than 1000.
Can anybody help me with the bash script or some other shell script.
Thanks
texasweb
May 10 2006, 07:51 AM
We have no script gurus that can help me out. 43 people have viewed it and no takers. Please, someone help me. I can figure it out, but it will take me a little bit. I figured with the expertise in this forum that someone could supply some code in about 2 minutes.
Thanks
Wayne Stevens
Catalyst
May 10 2006, 09:17 AM
Set it up as cron script:
CODE
#!/bin/sh
DATE="`date '+%Y%m%d%H%M'`"
NUM="`qstats | sed -e 's/messages in queue: //'`"
if [ $NUM -gt 999 ]; then
echo "cleanqueue kicked off at $DATE";
cleanqueue
fi
texasweb
May 10 2006, 09:54 AM
Thanks so much for the help.. kudos.
Galactic Zero
May 14 2006, 08:51 AM
You could probably also us qmHandle and run it as a cron job..
qmHandle -Sfailure is the command to purge all messages with failure in the subject line.
Here is the command set for qmHandle:
[root@gz bin]# qmHandle
qmHandle v1.2.0
Copyright 1998-2003 Michele Beltrame
Available parameters:
-a : try to send queued messages now (qmail must be running)
-l : list message queues
-L : list local message queue
-R : list remote message queue
-s : show some statistics
-mN : display message number N
-dN : delete message number N
-Stext : delete all messages that have/contain text as Subject
-D : delete all messages in the queue (local and remote)
-V : print program version
Additional (optional) parameters:
-c : display colored output
-N : list message numbers only
(to be used either with -l, -L or -R)
You can view/delete multiple message i.e. -d123 -v456 -d567
[root@gz bin]#
Squire
May 14 2006, 04:03 PM
One caveat with qmHandle, which I use and recommend myself btw.
If you write a cron job to dump mass messages, make sure your script stops qmail first. Otherwise you could end up fubar'ing your qmail queue. Leaving a few seconds in there to make sure qmail has totally stopped is a good idea too if you try to automate things with it.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please
click here.