![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Setting cronjobs... | krworks | Shell Programming and Scripting | 4 | 06-06-2008 02:46 AM |
| control over shell script | JLJ | Shell Programming and Scripting | 3 | 01-22-2007 02:16 AM |
| using regular expressions in c shell control structure | ballazrus | Shell Programming and Scripting | 3 | 02-20-2006 12:59 AM |
| Cronjobs | mcastill66 | AIX | 1 | 05-31-2005 02:15 PM |
| cronjobs | tamer | UNIX for Dummies Questions & Answers | 3 | 01-22-2001 02:48 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
How to Control Cronjobs using Shell Script??
Hi All,
Now i am running the 3 oracle procedures one by one manually. Query: If 1st Procedure OUT_PUT is Success, then call 2nd Procedure. If 2nd Procedure OUT_PUT is Success, then call 3rd Procedure. If 1st Procedure is failed, then no need of calling the other procedures. How to Schedule 1st, 2nd, 3rd Procedures jobs are@ ############################################### SCHEDULE JOBS ############################################### # 30 01 * * * /u14/ods/scripts/in_pps_state_change.sh >> /u14/ods/scripts/scriptslog/in_other_mail.log 2>&1 # 00 03 * * * /u14/ods/scripts/in_pps_cos_change.sh >> /u14/ods/scripts/scriptslog/in_other_mail.log 2>&1 # 30 04 * * * /u14/ods/scripts/in_pps_usage_change.sh >> /u14/ods/scripts/scriptslog/in_other_mail.log 2>&1 ################################################ CALLING ORACLE PROCEDURE FROM SHELL SCRIPT ################################################ Eg of SP calling:: in_pps_usage_change.sh RETVAL=`sqlplus -s ODS/ODS@ODSDB <<EOF SET SERVEROUTPUT ON SIZE 100000 Declare OUT_STATUS NUMBER; OUT_MSG VARCHAR2(200); Begin ODS_SP_REMOVE_PRE_SUB_DUP(OUT_STATUS, OUT_MSG); dbms_output.put_line ('KeepThis '||OUT_STATUS ||' '||nvl(OUT_MSG,'')); End; / SET SERVEROUTPUT OFF EXIT; EOF` X=`echo $RETVAL | grep KeepThis | awk '{print $2}'` Y=`echo $RETVAL | grep KeepThis | awk '{print $3}'` echo " " >> $USER_LOG echo "Procedure: ODS_SP_REMOVE_PRE_SUB_DUP output is: " >> $USER_LOG echo "OUT_STATUS= $X" >> $USER_LOG echo "OUT_MSG= $Y " >> $USER_LOG ################################################ Please provide me the solution of my query.. Thanks&Regards Hanuma |
|
||||
|
Why don't you keep them all in a single script, and start that at 01:30? Then it's much easier to see if the first subjob failed.
Code:
if in_pps_state_change.sh; then in_pps_cos_change.sh in_pps_usage_change.sh fi Code:
if in_pps_state_change.sh; then # Todo: maybe die a horrible death if the time is already past 03:00 echo /u14/ods/scripts/in_pps_cos_change.sh | at 03:00 echo /u14/ods/scripts/iin_pps_usage_change.sh | at 04:30 fi Last edited by era; 03-18-2008 at 07:40 AM.. Reason: Add "at" example |
|
||||
|
Quote:
|
|
||||
|
I have one more dought??
If the 1st procedure is executed, but process is not done due to ORA- 03113 : End of Comminication channel Error. In this case IF LOOP can run the 2nd & 3rd Procedures successfully ????? Any solution is there, to control 2nd, 3rd procedures??? |
|
||||
|
You should also take care to set the exit code properly from the script, so that the shell script which collects these can examine it.
I guess something like if OUT_STATUS is "Success" exit 0, otherwise some higher number (0 means success). You are in control of the first shell script (and if not, create a wrapper script which you are in control of), so simply make it return success (zero) under the conditions when the second and third scripts can be run, and non-zero if not. Last edited by era; 03-18-2008 at 08:28 AM.. Reason: Answer to most recent question, too |
|
||||
|
Quote:
Thanking you.... |
| Sponsored Links | ||
|
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|