Clustering and cronjobs

Christopher Browne cbbrowne-Re5JQEeQqe8AvxtiuMwx3w at public.gmane.org
Tue Aug 15 15:02:45 UTC 2006


On 8/15/06, Zu Zhihui (祖志辉) <zuzhihui at gmail.com> wrote:
> Assume your shared storage is mounted on /opt/data
> Use the following script as your cron script.
>
>
> mountpoint -q /opt/data
> if [ $? -eq 0 ]; then
>    echo "this is the active node"
>    #execute some scripts.
> else
>    echo "this is not the active node, do nothing"
> fi

There's probably also an IP address associated with the active node.

So, if IFCONFIG is set to something suitable like /sbin/ifconfig, and
ACTIVEIP is set to the IP address of the IP that the active node
claims, then...

if [[ `${IFCONFIG} -a | grep "${ACTIVEIP}"` ]] ; then
  echo "this is the active node"
  # Do some stuff on the active node
else
  echo "These are not the droids you're looking for; you can go about
your business"
fi
-- 
http://www3.sympatico.ca/cbbrowne/linux.html
Oddly enough, this is completely standard behaviour for shells. This
is a roundabout way of saying `don't use combined chains of `&&'s and
`||'s unless you think Gödel's theorem is for sissies'.


More information about the Legacy mailing list