Run Jobs in Order


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Run Jobs in Order
# 1  
Old 04-01-2012
Run Jobs in Order

Hi All,

This might be a silly question and sorry but I didn't know where to start with this.

I have a process I need to run 31 times and they must be one after another e.g. Only run after the other has run.

It will call a script that I have that runs 3 other processes in order (and works - test). Any ideas? here is my current script for one run


Code:
#!/bin/bash
 
# Setup
if [[ "xHOME" = "x" ]]; then
  source ~/.bash_profile
fi
if [[ "x$p_ls_home" == "x" ]]; then
  source ${HOME}/.profile.bob
fi
args="$@"
 
run die PRODUCTION $args
die_rc=$?
 
run mp PRODUCTION $args
mp_rc=$?
if [ "${die_rc}" -eq "0" ]; then
  if [ "${mp_rc}" -eq "0" ]; then
    run br PRODUCTION $args
    rc=$?
  else
    rc=$msp_rc
  fi
else
  rc=$die_rc
fi
exit $rc

Maybe I need another script to re-run 31 times based or x times ? I dont know how.
31 times is the number of days in the month. So this can be configurable

Moderator's Comments:
Mod Comment Welcome to the forum. Please use [code][/code] tags and preferably proper indentation for readability...

Last edited by Scrutinizer; 04-01-2012 at 02:26 PM..
# 2  
Old 04-01-2012
Your requirement is confusing to me. It looks little bit like you got a shell script and do not know what to do with it.

This is what I'm giving you: a loop to run the script 31 times. But I'm pretty sure that really is not what you need. The $cnt is 1 .. 31, myscript.sh is the name of your script:
Code:

#!/bin/bash
cnt=1
while [ $cnt -lt 32 ]
do 
   ${HOME}/myscript.sh $cnt

cnt=$(( $cnt + 1 ))
done 

Now, please tell us what you are trying to do, and what arguments your script needs.
We see what you did, we do not see really what you need to do.
# 3  
Old 04-01-2012
Hi Jim,

Sorry for any confusion.

I needed to repeat the supplied script as many times as needed.
For example if I input 1120301 and want a months worth of data it would need to run from 1120301 to 1120331.

Date format is CYYMMDD.

The reason I wanted a script is each run takes up to 1 hour and didnt want to wait 31 hours...

Does that explain it? Or am i still a little too vague

---------- Post updated at 06:35 PM ---------- Previous update was at 02:57 PM ----------

Hi,

Thanks for the tips. I think I'm getting the hang of it. I just need to call my script in the loop:

Code:
        date=`date +%C%y%m%d`
        lastmonth=`date --date="last month" +%C%y%m`
        firstday="${lastmonth}01"
        lastday=`date --date="$firstday +1 month -1 day" +%C%y%m%d`
        export p_MONTHSTART=`echo "${firstday} - 19000000" | bc`
        export p_MONTHEND=`echo "${lastday} - 19000000" | bc`
        echo "Start: ${p_MONTHSTART}, End: ${p_MONTHEND}"
 
        while [ $p_MONTHSTART -lt $p_MONTHEND ]
        do
                echo $p_MONTHSTART
                sleep 5
        p_MONTHSTART=$(( p_MONTHSTART + 1 ))
        done

# 4  
Old 04-03-2012
Date format is CYYMMDD .
The commands posted suggest that you mean CCYYMMDD.
Please clarify.

Btw: date +%Y gives the year as CCYY, or in more conventional notation YYYY.



Quote:
if I input 1120301
Can't extract a sensible year field from this data, unless you mean the year 112 years after the birth of Christ.
120301 interpreted as yymmdd in current context would be 1st of March 2012. For total unambiguity it should be yyyymmdd i.e. 20120301 - the only way to hold dates in life insurance systems.

Last edited by methyl; 04-03-2012 at 08:41 PM.. Reason: typos
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. 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

2. Shell Programming and Scripting

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... (3 Replies)
Discussion started by: santoshkumarkal
3 Replies

3. Shell Programming and Scripting

Run multiples jobs in background mod

Hi, I have a problem runnig from script two diferents process in background mod. Is there a limitation to do this? For example echo "Running process one:" ./ProcessOne & echo "Running process two:" ./ProcessTwo & echo "The process are runnig. Bye" The problem is that the... (7 Replies)
Discussion started by: Xedrox
7 Replies

4. Shell Programming and Scripting

specific number jobs run at the same time

Hi, I have more that 100 jobs I can run background, if I want only 4 running at ther same time, how can I write a script to control it? Thanks peter (0 Replies)
Discussion started by: laopi
0 Replies

5. Shell Programming and Scripting

commands to be executed in order for a batch jobs!

Hi All, I am trying to run this script. I have a small problem: each "./goada.sh" command when done produces three files (file1, file2, file3) then they are moved to their respective directory as can be seem from this script snippet here. The script goada.sh sends some commands for some... (1 Reply)
Discussion started by: faizlo
1 Replies

6. Shell Programming and Scripting

Creating a Schedular to Run the Jobs.

Hi, I have to create a sheduler to run the shell scripts one by one(dependency). Suppose i have 10 scripts. For all the 10 scripts i have a database table containing these scripts_names and status. Executing the first script.if the first status script is only 'success' then go to next... (4 Replies)
Discussion started by: laknar
4 Replies

7. UNIX for Dummies Questions & Answers

Please help me with the run-away cron jobs

I started a cron job on a cluster super computer. I am just a usual user over there and has no root power. The cron job was set by using "crontab -e". It excecutes a perl command every 20 minutes. I could use crontab -l or crontab -r to list or remove the cron job. However, I just found that I... (2 Replies)
Discussion started by: dedema
2 Replies

8. Shell Programming and Scripting

limit the number of jobs to run.

i just want to get the BackGround status and limit the number of jobs to run the at a time. can i able get the back ground exit status ? that i code below. can jobs -l limit the number of jobs to run ? total is this script looks fine ? cat run_job.ksh #!/usr/bin/ksh... (0 Replies)
Discussion started by: GrepMe
0 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. Linux

cron jobs not run

hi, I am newbie, I had set cron jobs to update something on one time very day, I had tested the script, it run fine, but the cron jobs seem never run. some help? Thanks. (4 Replies)
Discussion started by: robertsnoog
4 Replies
Login or Register to Ask a Question