Shell script to run multiple jobs and it's dependent jobs


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Shell script to run multiple jobs and it's dependent jobs
# 1  
Old 01-30-2016
Shell script to run multiple jobs and it's dependent jobs

I have multiple jobs and each job dependent on other job.
Each Job generates a log and If job completed successfully log file end's with JOB ENDED SUCCESSFULLY message and if it failed then it will end with JOB ENDED with FAILURE.

I need an help how to start.

Attaching the JOB dependency .... Please help me here how to start.
Shell script to run multiple jobs and it's dependent jobs-jobspng
# 2  
Old 01-30-2016
My old eyes are having difficulty deciphering the names of your jobs. And, with lines running through or behind some jobs, not all of the dependencies are clear.

Do you really have to read the log files to determine whether a job completed successfully? Why aren't your jobs written to exit with a zero exit status on successful completion and a non-zero exit status on failure? If you do have to decipher log files, what are the names of the log files?

What arguments need to be passed to your jobs? What I/O redirections need to be set up for your jobs?
This User Gave Thanks to Don Cragun For This Post:
# 3  
Old 01-31-2016
Quote:
Originally Posted by Don Cragun
My old eyes are having difficulty deciphering the names of your jobs. And, with lines running through or behind some jobs, not all of the dependencies are clear.

Do you really have to read the log files to determine whether a job completed successfully? Why aren't your jobs written to exit with a zero exit status on successful completion and a non-zero exit status on failure? If you do have to decipher log files, what are the names of the log files?

What arguments need to be passed to your jobs? What I/O redirections need to be set up for your jobs?
Thank you for your reply.

My log name starts with name of the job ... If suppose Job name is X then log name will starts with X.
No arguments needed.. just we need to run in below format.
RunJobs X BYREQ ( Format to run the job).
We can run the job from any path and it creates the log at Home directory.
# 4  
Old 01-31-2016
Moderator's Comments:
Mod Comment I am moving this thread to a technical forum. If you posted in the Post Here to Contact Site Administrators and Moderators forum hoping a site administrator or moderator would magically create a script for you, that is not what the UNIX & Linux Forums is here for. We are not your unpaid programming staff. We are here to help you learn how to write your own code.

Please review the forum rules you agreed to when you joined this forum.


I repeat: Do you really have to read the log files to determine whether a job completed successfully? Why aren't your jobs written to exit with a zero exit status on successful completion and a non-zero exit status on failure? If you do have to decipher log files, what are the names of the log files?

And, what operating system and shell are you using?

With a shell based on Bourne shell syntax, you can run a job and the shell variable $? will be set to the exit status of the last command completed.

When you get to a point where you want to run more than one job in parallel, you can start a job in the background using something like:
Code:
RunJobs X BYREQ &

(with the & telling the shell to run the command preceding the ampersand in the background) and immediately after that you can use something like:
Code:
Xpid=$!

which will then save the process ID of the job you just started in the background. Then when you have started all of the processes in the background that can run independently, you can wait for the completion of that job with:
Code:
wait $Xpid

and the exit status of the wait command will be the exit status of that job.

You can then paste these pieces together with shell commands to determine whether to start other jobs (if the dependencies completed successfully) or quit (if one of the dependencies failed).

If you can't use the exit status of a job to determine if it succeeded, you can use something like:
Code:
if grep -q SUCCESSFULLY JobXlogfile
then	DoWhateverYouNeedToDoOnSuccessfulCompletion
else	DoWhateverYouNeedToDoOnFailure
fi

In all cases in the above examples, everything in italics needs to be replaced by code you supply and all cases of X need to be replaced by your job names.

This should be enough to give you an idea of where to start. But, a project like this is fairly complex if this is your first attempt at writing a shell script.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Script to read file and run multiple jobs

I have a txt file line1 line2 line3 $!/bin/sh cat /tmp/lus.txt | while read line do esxcli storage vmfs unmap -u $lin -n 4000 done this works but does in one line at a time. how do I do all lines at once simutaeously? Please use CODE tags as required by forum rules! (4 Replies)
Discussion started by: tdubb123
4 Replies

2. UNIX for Beginners Questions & Answers

How to run multiple cron jobs?

I have two scripts which I'm tying to run one after the other- this is what I've tried: 00 14 * * * /path/one.sh && /path/two.sh I've also tried putting each script on a different line: 00 14 * * * /path/one.sh 00 14 * * * /path/two.sh Can this be done? (1 Reply)
Discussion started by: $shell_Learner
1 Replies

3. Shell Programming and Scripting

UNIX script to check multiple jobs runninng status

Hi Folks, Please help me ,I need a unix shell script to check for multiple jobs running. if there are multiple backup Jobs running then it should be trigger an email . Thanks, Anand T (1 Reply)
Discussion started by: nandu67
1 Replies

4. Shell Programming and Scripting

Calling multiple jobs from single shell script

Hi all, I have developed a shell script where I am executing datastage jobs.This script will be further placed in enterprise scheduler to trigger it at particulat time. I have around 300 jobs , I am passing jobnames to script as a paramere. So is it possible I can trigger all jobs from one... (3 Replies)
Discussion started by: prasson_ibm
3 Replies

5. Shell Programming and Scripting

waiting on jobs in bash, allowing limited parallel jobs at one time, and then for all to finish

Hello, I am running GNU bash, version 3.2.39(1)-release (x86_64-pc-linux-gnu). I have a specific question pertaining to waiting on jobs run in sub-shells, based on the max number of parallel processes I want to allow, and then wait... (1 Reply)
Discussion started by: srao
1 Replies

6. Shell Programming and Scripting

General Q: how to run/schedule a php script from cron jobs maybe via bash from shell?

Status quo is, within a web application, which is coded completely in php (not by me, I dont know php), I have to fill out several fields, and execute it manually by clicking the "go" button in my browser, several times a day. Thats because: The script itself pulls data (textfiles) from a... (3 Replies)
Discussion started by: lowmaster
3 Replies

7. Shell Programming and Scripting

1 script or multiple scripts?? - check files, run jobs

Question for anyone that might be able to help: My objective is to eheck if a file (a source file) exists in a directory. If it does then, I'd like to call an application (Informatica ETL file...not necessary to know) to run a program which extracts data and loads it into multiple targets. ... (6 Replies)
Discussion started by: jnanasakti
6 Replies

8. HP-UX

how can i make two dependent jobs into cron?

Hi all, How can i make two dependent jobs into crontab? means after the first job the second job should run in a single crontab entry in unix. (1 Reply)
Discussion started by: megh
1 Replies

9. Shell Programming and Scripting

background jobs exit status and limit the number of jobs to run

i need to execute 5 jobs at a time in background and need to get the exit status of all the jobs i wrote small script below , i'm not sure this is right way to do it.any ideas please help. $cat run_job.ksh #!/usr/bin/ksh #################################### typeset -u SCHEMA_NAME=$1 ... (1 Reply)
Discussion started by: GrepMe
1 Replies

10. Shell Programming and Scripting

How to write a Script to run series of batch jobs on unix platform

Im new to unix shell scripting, I have to run batch jobs on unix. for example i have 5 jobs. first 2 can kickoff parallely. after completely finishing the 2 previous jobs the 3 job should kick off..once 3rd is over 4 th and 5th can kick off parallely. Each jobs run for 1 or 2 hours each. How to... (2 Replies)
Discussion started by: venki311
2 Replies
Login or Register to Ask a Question