Visit Our UNIX and Linux User Community

Loop to execute 2 times and send an email alert

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Loop to execute 2 times and send an email alert
# 1  
Old 09-22-2017
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

Last edited by thomas9192; 09-25-2017 at 10:55 AM.. Reason: fixed code tags
# 2  
Old 09-22-2017
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).

Previous Thread | Next Thread
Test Your Knowledge in Computers #632
Difficulty: Easy
Apple development of what would become the iPhone began in 2004.
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Loop multiple directory, find a file and send email

Hello ALL, need a BASH script who find file and send email with attachment. I have 50 folders without sub directories in each generated files of different sizes but with a similar name Rp01.txt Rp02.txt Rp03.txt ...etc. Each directors bound by mail group, I need a script that goes as... (1 Reply)
Discussion started by: penchev
1 Replies

2. Shell Programming and Scripting

Parse qshape output and send email alert

Hi I need help to do this. This is the output of qshape: user$ qshape deferred|head T 5 10 20 40 80 160 320 640 1280 1280+ TOTAL 0 0 0 0 0 0 0 0 0 0 0 T stands for minutes elapsed and TOTAL... (1 Reply)
Discussion started by: zorrox
1 Replies

3. Shell Programming and Scripting

Reset while loop to loop same file multiple times

Hi, I want to read file multiple times. Right now i am using while loop but that is not working. ex. While read line do while read line2 do echo stmt1 #processing some data based on data., done < file2.txt done < file1.txt # This will have 10... (4 Replies)
Discussion started by: tmalik79
4 Replies

4. Shell Programming and Scripting

Using top command to email if process is exceeding 25% and sending an email alert if so

This is my first time writing a script and Im having some trouble, Im trying to use the top command to monitor processes and the amount of CPU usage they require, my aim is to get an email if a process takes over a certain percentage of CPU usage I tried grep Obviosly that hasnt worked, Any... (8 Replies)
Discussion started by: jay02
8 Replies

5. Shell Programming and Scripting

Logic to send email alerts only 5 times a day

Hi, I have written below disk space monitoring script to monitor disk space every minute. I have scheduled this script through cron. But now my problem is this script alerts the users continuously until the space is freed up. These emails are filling up the inbox exponentially until the space... (3 Replies)
Discussion started by: svajhala
3 Replies

6. Shell Programming and Scripting

Script to send email after comparing the folder permissions to a certain permission & send email

Hello , I am trying to write a unix shell script to compare folder permission to say drwxr-x-wx and then send an email to my id in case the folders don't have the drwxr-x-wx permissions set for them . I have been trying to come up with a script for few days now , pls help me:( (2 Replies)
Discussion started by: nairshar
2 Replies

7. AIX

How to send alert by email whenever failed login

Hi, I want to write a script to send alert by email whenever any failed login to the AIX. Can anyone tell how to do that? Thanks! Victor (1 Reply)
Discussion started by: victorcheung
1 Replies

8. Solaris

Shell script to send email alert for core dump

Friends, I am in search for a shell script that is capable of running as a cronjob and have to send out an email when ever there is a CORE DUMP. Please post the hints to achieve my goal. Thanks in advance. (1 Reply)
Discussion started by: rtatineni
1 Replies

9. UNIX for Dummies Questions & Answers

Help? Any method to send system alert email?

Dear All, I am a newer of Unix Administrator. I would like to know any way to make Unix syslog critical error send automatically to me by email. Then I don't need to check it manually and frequency everyday. Any suggestion? Thanks for all your kindly help. Jacky (1 Reply)
Discussion started by: ITJacky
1 Replies

10. UNIX for Advanced & Expert Users

Unable to send eMail from a UNIX-Host ( using mailx ) to a Outlook-email-addres(Win)

Hi A) I am able to send eMail using mailx from a UNIX ( solaris 8 ) host to my Outlook-email-ID : ( This is NOT my actual -eMail-ID). But in Outlook the "From :" eMail address is displayed as " " .i.e the words... (2 Replies)
Discussion started by: Vetrivela
2 Replies

Featured Tech Videos