Sponsored Content
Top Forums Shell Programming and Scripting Retries in shell programming. Post 302425422 by singh.chandan18 on Friday 28th of May 2010 12:03:07 AM
Old 05-28-2010
Retries in shell programming.

Hello Friends,

I am writng a shell script which will call another script startServer and then execute one more script pingServer to check if the server is up.

As it takes sometimes for the server to start, so I have defined an until loop to check the status of the server until the server is up, by calling the pingServer script again.

I want pingServer script to be executed 4 times in every 4 minutes before terminating the loop.

I've already written a script, so need your guidance and suggestions(mainly in Retries statement) in making the script better.

Code:
 
Scr_Dir=/dise/vclwrk33/J2EEServer/config/ABP-FULL/ABPServer/scripts
Log_File=/tmp/Enabler_Check.log
  Server_Stat=""
  Retries=0
  Retry_Max=4
#Checking if the script is executable by the current process
    if [ -x $Scr_Dir/startServer ]
    then
            echo "Starting the Server now...." >> $Log_File
            $Scr_Dir/startServer > /dev/null 2>&1
             sleep 60
#Until loop to check the status of the server until the server is up
        until [ $Server_Stat = UP ]
        do
              $Scr_Dir/pingServer | grep UP
              if [ $? -eq 0 ]
              then
                      Server_Stat= UP
                      echo "/n Server has been started successfully..../n" >> $Log_File
              else
#Retrying 4 times in every 4 mins
                      Retries=$( expr $Retries + 1 )
                        if [ $Retries -gt $Retry_Max ]
                        then
                             echo "Timed out in starting the Server.." >> $Log_File
                             exit 1
                        else
                             sleep 240
                        fi
             fi
       done
     else
                echo "Error Executing startServer script..." >> $Log_File
                exit 1
     fi

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Shell Programming Help

Hi, I am new to shell programming, and hve been given a request to write a shell script. Is there any good places to go to see examples of how to write shell programming scripts? Thanks (4 Replies)
Discussion started by: mec585858
4 Replies

2. Shell Programming and Scripting

Shell Programming?

For what purposes should we use shell /what are the tasks we can achieve using shell which is best book to learn shell programming and will nayone tell me diff between shell programming aand shell scripting? Thank u in advance. (1 Reply)
Discussion started by: shrikrishna
1 Replies

3. Shell Programming and Scripting

Shell Programming

Provides a menu structure that allows a user to select several options - input a name and address, lookup a name and address, delete a name and address, and print a formatted report from a text database (note: this requirement assumes that you will use the program to create a database, though in... (1 Reply)
Discussion started by: DonOmar
1 Replies

4. UNIX for Advanced & Expert Users

Sendmail retries sending to non-existant users

How can i get sendmail to immediately bounce mail when the server on the other side gives a "550 unknown user" SMTP error? Currently, the outbound mail stays in the queue and is retried until our server gives up, some days later. (0 Replies)
Discussion started by: vertigo23
0 Replies

5. Solaris

Solaris 2.6:max login retries

HI, I'm on Solaris 2.6. Where do I set the max login retries? Pls help!! (1 Reply)
Discussion started by: mad_chung
1 Replies

6. Shell Programming and Scripting

shell programming

Hi iam new to shell programming. I would like to ask one dought abt the file handling in unix. Iam having a file1 as follows: ASDERFCX1234567890123456 POIUYTRE0098765432123456 BVCXCVBN0955644411111111 File2 ASDERFCX1234567890123456 kill@abc.com ... (8 Replies)
Discussion started by: nivas
8 Replies

7. Shell Programming and Scripting

need help for shell programming

My purpose was to print out all of name of students in a list.First of all,I created a file name "List" in /home/tuan/Desktop/Shell_programming as below Tom Henry Ben Linda Marry And my script "script" is #!/bin/sh path=/home/tuan/Desktop/Shell_programming/List for student in $path... (3 Replies)
Discussion started by: thungmail
3 Replies

8. Shell Programming and Scripting

Shell programming

Hi i need a favour i have a file which has some trillions of records. The file is like this 11111000000000192831840914000000000000000000000000000 45789899090000000000000000011111111111111111111111111 I want to cut specific postions in each line like cut1-3 and assisgn it to a variable and... (0 Replies)
Discussion started by: richa2.m
0 Replies

9. Shell Programming and Scripting

Shell programming

Hi every one,i am new to unix.Can any one tell me about shell programming.. (1 Reply)
Discussion started by: martina100011
1 Replies

10. UNIX for Dummies Questions & Answers

Shell script to read lines in a text file and filter user data Shell Programming and Scripting

sxsaaas (3 Replies)
Discussion started by: VikrantD
3 Replies
RBASH(1)						      General Commands Manual							  RBASH(1)

NAME
rbash - restricted bash, see bash(1) RESTRICTED SHELL
If bash is started with the name rbash, or the -r option is supplied at invocation, the shell becomes restricted. A restricted shell is used to set up an environment more controlled than the standard shell. It behaves identically to bash with the exception that the follow- ing are disallowed or not performed: o changing directories with cd o setting or unsetting the values of SHELL, PATH, ENV, or BASH_ENV o specifying command names containing / o specifying a file name containing a / as an argument to the . builtin command o specifying a filename containing a slash as an argument to the -p option to the hash builtin command o importing function definitions from the shell environment at startup o parsing the value of SHELLOPTS from the shell environment at startup o redirecting output using the >, >|, <>, >&, &>, and >> redirection operators o using the exec builtin command to replace the shell with another command o adding or deleting builtin commands with the -f and -d options to the enable builtin command o using the enable builtin command to enable disabled shell builtins o specifying the -p option to the command builtin command o turning off restricted mode with set +r or set +o restricted. These restrictions are enforced after any startup files are read. When a command that is found to be a shell script is executed, rbash turns off any restrictions in the shell spawned to execute the script. SEE ALSO
bash(1) GNU Bash-4.0 2004 Apr 20 RBASH(1)
All times are GMT -4. The time now is 03:36 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy