Hi,

Bhyrava Prasad typed:
>    I am looking for ideas to do load balancing , so that
> mails to this account are distributed fairly (not 
> necessarily equally) between a set of people (configurable
> from some file , perhaps).

Create a file called "addresses" and put all the addresses in it, one
on each line. The following bash script maintains the last user sent
to in a file "lastsent". It then increments it (and wraps around to
zero) and gets that user from the file "addresses", and pipes stdin to
sendmail which sends it to that particular address.

Create a sendmail alias for the main user, which pipes mail to this
script. Or you can use procmail to do the same.

----- 

#!/bin/sh
lockfile lastsent.lock          
if [ -f lastsent ];
then
        userid=$(cat lastsent)
else
        userid=-1
fi
usercount=`cat addresses | wc -l`
userid=$[($userid+1)%$usercount]
echo $userid > lastsent
rm -f lastsent.lock

i=0;
for user in `cat addresses`;
do
        if [ $i -eq $userid ];
        then
                cat | /usr/lib/sendmail -oi -oem $user
                break
        fi
        i=$[$i+1]
done

-----

HTH..

-- 
Mrinal Kalakrishnan <[EMAIL PROTECTED]> http://mrinal.dhs.org/
Linux 2.2.15 || PGP:B1E86F5B || Mutt 1.3.2i (2000-05-23) || VIM 5.5 
-- 
There are no threads in a.b.p.erotica,  so there's no  gain in using a
threaded news reader.
(Unknown source)

-----------------------------------------------------------------------
The LIH mailing list archives are available at:
http://lists.linux-india.org/cgi-bin/wilma/linux-india-help

Reply via email to