Loop to execute 2 times and send an email alert

After the successful start of server, it should check the status again, if it is not running ,it should go through the loop for 2 times.
Even after two times of execution if still the server is not running it should send an alert email. Please help

It is hard to make many comments about whether or not your code is likely to succeed or where it might be failing with all of the variables you're using that (as far as we can tell) have never been set.

Not knowing whether some of the scripts you invoke wait for application startup to complete before returning means that we have no idea whether or not the scripts you invoke to get the status of your application have built-in race conditions.

And, implying that your script is failing, but not clearly describing what is not working correctly leaves us making lots of guesses and assumptions that are probably wrong.

I can also say that your erratic indenting serves to hide the structure of your code. Please learn to line up related while , do , and done keywords; if , then , else , and fi keywords; for , do , and done ; etc. and consistently indent code that is in a while , for , then , else , etc. clause.

Please take some time to explain what your variables are supposed to contain and show us how they are initialized. Explain what the scripts you invoke are supposed to do, whether or not you know that they work correctly (if you invoke them correctly), and show us the outputs that they produce (in CODE tags). And, clearly explain what is working correctly (if anything) and what is failing (and explain the symptoms of those failures). Show us the output produced by running your script with tracing enabled ( set -xv ) (again, in CODE tags).