Created
January 20, 2013 10:11
-
-
Save justyns/4577655 to your computer and use it in GitHub Desktop.
Automatically spawn exim queue runners if a queue is detected
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# eximqueue.sh - 07/30/2012 - Justyn Shull <justyn [at] justynshull.com> | |
messages=`exim -bpc` | |
maxmessages=120 | |
maxrunners=50 | |
while [ 1 ]; do | |
messages=`exim -bpc` | |
currunners=`ps afx | grep '/usr/sbin/exim -q' | wc -l` | |
echo -n "." | |
if [ $currunners -lt $maxrunners ]; then | |
if [ $messages -gt $maxmessages ]; then | |
echo -e "Current queue: $messages \t `uptime`" | tee -a /root/eximqueue.log | |
echo "`date`: There is a queue of $messages, spawning $maxrunners queue runners" | tee -a /root/eximqueue.log | |
counter=0 | |
while [ $counter -lt $maxrunners ]; do | |
#echo -n "Spawned $counter " | |
echo -n "+" | |
/usr/sbin/exim -q & | |
let counter=counter+1 | |
done | |
fi | |
fi | |
sleep 1 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment