Restart Logic for a Korn Shell Master Script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Restart Logic for a Korn Shell Master Script
# 1  
Old 07-02-2010
Error Restart Logic for a Korn Shell Master Script

Hello All,

I was wondering if someone can help me to develop restart logic for a Korn Shell program (a master script) that I am developing. The program is design to invoke a series of child processes (Korn Shell Scripts) whose function is to create a series of load files on a specified mount point. These child processes pass a return code (0 or none zero) to the parent script. If a return code greater than 0 is passed to the parent script, the parent script is terminated. I want to be able to restart the parent script and for it to start processing or invoking the child processes at the point at which the failure occurred.

Since I am using a series of arrays to invoke the child processes, I am sending the name of each landed load file to a >> $loadrecord file. I know that I can use this loadrecord file in the restart logic, but I do know how to construct the code to accomplish this task. The code that follows is the base code that I use to invoke my child processes.

Code:
echo "$(date) : Initializing the data collection process ...."
# Initializing counter
i=0
while [[ $i -lt ${#delfile[*]} ]] ; do
 if [[ ! -a ${delfile[i]} && ! -a $statfile_ddw0 ]] ; then
     echo "$(date): Beginning the data flow ${loadfile[i]} ...."
       ((dataldprod+=1))
     ${loadfile[i]}
     RC=$?
       if [[ $RC -ne 0 ]] ; then
          echo "$(date) : An error occurred during the processing of ${loadfile[i]} : Error Code : $RC"
          exit $RC
       else
          echo "$(date) : ${loadfile[i]} has been successfully processed ... Error Code : $RC"
          echo "$(date) : $dataldprod load file has been created ...."
          echo  ${loadfile[i]} >> $loadrecord
          ssh $FTPHOST_DDWTST0 "$DDWTST0_LOAD_SUBDIR_LOAD_FILE/men_str_ctrl_script_ddwtst0.ksh"
       fi
 else
       echo "$(date) : There is a load file waiting in the mount directory to be transferred to DDWTST0"
       sleep 300
 fi
((i+=1))
done

Any help you can give me will be appreciated.

Thanks,
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to restart shell script when cpu is 0.0%?

Hello, My operating system is ubuntu 16.04. I need to kill or restart a shell script when cpu usage of related process is equal to 0.0% for X seconds. Appearing name on top page is vlc While surfing on forums, I found below script but not sure how to edit: Also don't know the function of -gt... (7 Replies)
Discussion started by: baris35
7 Replies

2. Shell Programming and Scripting

How to write config shell script to pass variables in master shell script?

Dear Unix gurus, We have a config shell script file which has 30 variables which needs to be passed to master unix shell script that invokes oracle database sessions. So those 30 variables need to go through the database sessions (They are inputs) via a shell script. one of the variable name... (1 Reply)
Discussion started by: dba1981
1 Replies

3. UNIX for Dummies Questions & Answers

How to write Config shell script to pass variables in master shell script?

Dear Unix gurus, We have a config shell script file which has 30 variables which needs to be passed to master unix shell script that invokes oracle database sessions. So those 30 variables need to go through the database sessions (They are inputs) via a shell script. one of the variable name... (1 Reply)
Discussion started by: dba1981
1 Replies

4. Shell Programming and Scripting

Restart logic in script

I have a question regarding the restart logic in scripts. I have a script named "JOB1" which has 5 steps and every step has a program. Suppose my script fails at 4th step and the first 3 steps have completed successfully. I want to start my script from 4th step directly without doing any change... (1 Reply)
Discussion started by: champ2108
1 Replies

5. UNIX Desktop Questions & Answers

How can I replicate master master and master master MySQL databse replication and HA?

I have an application desigend in PHP and MySQl running on apache web server that I is running on a Amazon EC2 server Centos. I want to implement the master-master and master slave replication and high availability disaster recovery on this application database. For this I have created two... (0 Replies)
Discussion started by: Palak Sharma
0 Replies

6. Shell Programming and Scripting

Shell script logic

Hi I have a requirement where I have to generate a mail/alert to the user if any QA check is failed. our oracle jobs run in unix environment and log file is created . Sample is given below . SELECT * FROM product.fact_tally WHERE period_id = '20130401' ; LIMIT 5; Ideally the above... (4 Replies)
Discussion started by: systemee
4 Replies

7. Shell Programming and Scripting

Logic in Shell script required

Hi, I have the following in my shell script sqlplus << EOF username/password @$SCRIPTS_DIR/refresh.sql > /home/oracle/sql/refreshsql.log EOF RETCODE=$? if ; then echo "ERROR: sqlplus command finished with error code {RETCODE}" /usr/bin/mailx -s "REFRESHING FMLA CONTACT... (2 Replies)
Discussion started by: welldone
2 Replies

8. Shell Programming and Scripting

restart logic in a script

Hi I have a script as follows Function func0 <Set of validations done> Function Func1 <Set of commands and some of the variables set> Function Func2 <Set of commands and some of the varibales set> Function Func3 <Call a job(It is a datastage job which is called> Main job Call func0... (2 Replies)
Discussion started by: dnat
2 Replies

9. Shell Programming and Scripting

perl script - adding restart logic

Hi all I have written a perl script which looks at one file and if new entry is made to that file then it runs some scripts depending upon the entry made to file( used File::Tail module ) . This script is running as “root” in nohup mode. Script works fine but I want to add restart logic. If... (4 Replies)
Discussion started by: zedex
4 Replies

10. Shell Programming and Scripting

suspend/restart a process in shell script

Hi, I have a task that Im stuck on. I have an elementary script named 'myscript' that prints "the script is running" once a second. It runs for 27 seconds. I need to write a 2nd script that starts 'myscript' and takes a parameter '$1' for a number. my 2nd script then needs to pause myscript... (1 Reply)
Discussion started by: daneensign
1 Replies
Login or Register to Ask a Question