Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have 4 cloud instances. First is a load balancer (LB), and then 2 instances with the identical setup holding the application code (APP1 & APP2). And finally, I have a database instance (DB).

  • DB: MySQL
  • Web service: Nginx

LB will route all requests to APP1 only. If APP1 goes down, LB will route requests to APP2.

I want to write a shell script that will execute only if LB is not routing requests to it.

So, I would have a shall script called on both, APP1 and APP2. If and only if LB routes requests to APP1, would on APP2 execute via cron.

Any idea how I can figure out, from APP2, if LB is routing requests to it?

share|improve this question
Is it possible for your script to log into the other machine and check (maybe via netstat / ps / lsof) if it is handling connections from the load-balancer? – Martin May 11 '11 at 14:32
Typically a load balancer will have an api through which you can remotely determine its current state. – Mark Wagner May 11 '11 at 17:21
Thanks for the responses. @Martin, I'd rather keep it within the machine. @embobo, I'm actually implementing the load balancer myself, via Nginx. Keeping it super simple :) – Housni May 11 '11 at 17:38

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.