The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



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

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 03-18-2008
hanu_oracle hanu_oracle is offline
Registered User
  
 

Join Date: Mar 2008
Location: MUMBAI, INDIA
Posts: 41
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
  #2 (permalink)  
Old 03-18-2008
era
Guest
  
 

Posts: n/a
Bits: 0 [Banking]
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
You could even run them with "at" if running them at a particular time is important. But then, you need to be sure that in_pps_state_change.sh finishes before the next job is due.

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
  #3 (permalink)  
Old 03-18-2008
era
Guest
  
 

Posts: n/a
Bits: 0 [Banking]
The actual shell script hurts to look at, but I guess you weren't soliciting criticisms for that (-:
  #4 (permalink)  
Old 03-18-2008
hanu_oracle hanu_oracle is offline
Registered User
  
 

Join Date: Mar 2008
Location: MUMBAI, INDIA
Posts: 41
Quote:
Originally Posted by era View Post
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
You could even run them with "at" if running them at a particular time is important. But then, you need to be sure that in_pps_state_change.sh finishes before the next job is due.

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
Thank you....
  #5 (permalink)  
Old 03-18-2008
hanu_oracle hanu_oracle is offline
Registered User
  
 

Join Date: Mar 2008
Location: MUMBAI, INDIA
Posts: 41
Quote:
Originally Posted by hanu_oracle View Post
Thank you....
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???
  #6 (permalink)  
Old 03-18-2008
era
Guest
  
 

Posts: n/a
Bits: 0 [Banking]
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
  #7 (permalink)  
Old 03-18-2008
hanu_oracle hanu_oracle is offline
Registered User
  
 

Join Date: Mar 2008
Location: MUMBAI, INDIA
Posts: 41
Quote:
Originally Posted by era View Post
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.
O.K,

Thanking you....
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 05:05 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0