Crontab query !!


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Crontab query !!
# 1  
Old 04-05-2013
Hammer & Screwdriver Crontab query !!

Hi,

I have three crontabs and each executes a PL-SQL query.

If all the three crontabs executed successfully, I want to execute the 4th crontab job immediately or else I would to skip executing the 4th crontab job and shoot an email.

How can this be achieved ?

Note: I have shell scripts from all 4 cronjobs as well as knowledge of how to shoot an email.
# 2  
Old 04-05-2013
Show how the cronjobs are scheduled in the first place. Your query is vague and explains only ur need. We need to know more details to help you.
# 3  
Old 04-05-2013
A crude way: Maintain a file that tells if the three cronjobs ran successfully or not. Have each of the three scripts write a success or failure value in this file. In the 4th script, read this file and check if there are three success values. If yes, then run the script, else don't.
# 4  
Old 04-05-2013
Quote:
Originally Posted by PikK45
Show how the cronjobs are scheduled in the first place. Your query is vague and explains only ur need. We need to know more details to help you.
00 11 * * * /home/ramesh/bin/connectdb1.sh
00 11 * * * /home/ramesh/bin/connectdb2.sh
00 11 * * * /home/ramesh/bin/connectdb3.sh
00 13 * * * /home/ramesh/bin/calculate.sh

calculate.sh should run only if first three cronjobs are successully executed else an email saying "Error in cronjob execution." should be triggered.

---------- Post updated at 05:26 AM ---------- Previous update was at 05:23 AM ----------

Quote:
Originally Posted by balajesuri
A crude way: Maintain a file that tells if the three cronjobs ran successfully or not. Have each of the three scripts write a success or failure value in this file. In the 4th script, read this file and check if there are three success values. If yes, then run the script, else don't.
The 4th script in a cronjob. How can I stop its execution upon failure ?

Are you saying let the 4th cronjob also run, read the value about failure in that file and self terminate itself ?
# 5  
Old 04-05-2013
Why can't you prepare a master script, since all the 3 major are running at the same time?

You can create a script that triggers off all the first three in order. You can store return codes of every sub script in 3 variables or the last one alone should do. If the return codes/code are fine then trigger the 4th else send a mail and exit

Hope this helps
# 6  
Old 04-05-2013
Quote:
Originally Posted by PikK45
Why can't you prepare a master script, since all the 3 major are running at the same time?

You can create a script that triggers off all the first three in order. You can store return codes of every sub script in 3 variables or the last one alone should do. If the return codes/code are fine then trigger the 4th else send a mail and exit

Hope this helps
I do not know how to return code from a script to a master script.

Can you please let me know how to ?
# 7  
Old 04-05-2013
This is how it is done.

Code:
#! /bin/sh

echo "Starting up 1st script"
/home/ramesh/bin/connectdb1.sh
rc1=$?
echo "Starting up 2nd script"
/home/ramesh/bin/connectdb2.sh
rc2=$?
echo "Starting up 3rd script"
/home/ramesh/bin/connectdb3.sh
rc3=$?

if [ $rc1 -eq 0 -a $rc2 -eq 0 -o $rc3 -eq 0 ]; then
echo "Starting up 4th script"
/home/ramesh/bin/calculate.sh
else
#mail logic here
exit
fi

echo "All scripts completed successfully"
exit

This User Gave Thanks to PikK45 For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell Script to execute Oracle query taking input from a file to form query

Hi, I need to query Oracle database for 100 users. I have these 100 users in a file. I need a shell script which would read this User file (one user at a time) & query database. For instance: USER CITY --------- ---------- A CITY_A B CITY_B C ... (2 Replies)
Discussion started by: DevendraG
2 Replies

2. UNIX for Dummies Questions & Answers

Query

Hi, I have a script to remove null values from a file. Could any one explain how this is working? :confused: while read f do echo process $f gawk... (0 Replies)
Discussion started by: abhi_n123
0 Replies

3. Shell Programming and Scripting

want to query : YES or NO

hi i want to make script. where i want to query from the user yes or no exp: do you want to proceed : y for yes n for NO. how this is possible in unix (3 Replies)
Discussion started by: dodasajan
3 Replies

4. Shell Programming and Scripting

Query Oracle tables and return values to shell script that calls the query

Hi, I have a requirement as below which needs to be done viz UNIX shell script (1) I have to connect to an Oracle database (2) Exexute "SELECT field_status from table 1" query on one of the tables. (3) Based on the result that I get from point (2), I have to update another table in the... (6 Replies)
Discussion started by: balaeswari
6 Replies

5. Shell Programming and Scripting

Query

hi i am producing txt outputs of archives created by our tsm software. problem is some of these files are too large to open in excel so i can despatch. here is a example of the output TAG_460 /prod_bak 7 FILE /ARCHIVE/Whistles- ... (4 Replies)
Discussion started by: treds
4 Replies

6. Shell Programming and Scripting

add the output of a query to a variable to be used in another query

I would like to use the result of a query in another query. How do I redirect/add the output to another variable? $result = odbc_exec($connect, $query); while ($row = odbc_fetch_array($result)) { echo $row,"\n"; } odbc_close($connect); ?> This will output hostnames: host1... (0 Replies)
Discussion started by: hazno
0 Replies

7. UNIX for Dummies Questions & Answers

Need Help on query

I just started to learn unix - need help to write a script to query a logfile and produce the results that contains a specific word "alarm" for a period from X day to Y day. I really have no idea how to begin - :( please help... ____________________________________________________ #... (1 Reply)
Discussion started by: snipfer
1 Replies

8. Shell Programming and Scripting

query.....

hi friends i want to know details of `exec` exact use of this command ..... actually i went through the man page but i didn`t get the satisfactory ...conclusion.... thaks in advance.... (1 Reply)
Discussion started by: newson
1 Replies

9. Shell Programming and Scripting

query

I have converted data written on excel sheet in unix through shell & perl prg now the problem is I want that if starting columns of the xls sheet is Blank than when data is converted into unix then it should appear with this '|' sign. but it appearing like this: hfgg|tytt| but I want like... (2 Replies)
Discussion started by: akash
2 Replies

10. UNIX for Advanced & Expert Users

query

hello, i am working as aix system administrator, what is the major difference between aix and sun solaris ..os. what r the area difficult in solaris for aix administrator .............................. (1 Reply)
Discussion started by: varadakumar
1 Replies
Login or Register to Ask a Question