Home » Infrastructure » Unix » Run parallel jobs
Run parallel jobs [message #253357] Mon, 23 July 2007 10:42 Go to next message
qasim845
Messages: 95
Registered: March 2007
Location: Philadelphia
Member

I have the folowing scripts. Is anybody help me to modify this scripts so i can run the second two sql jobs in parallel. The first sql job should run alone which is creating table, the second two are just to copy the data.So, i need those two copy jobs runs parallel.

Thanks in advance

#------------------------
# Define Functions
#------------------------

Run_SQL()
{
sqlplus -s $OUSER/$OPASS@$DBN @$1
}
GSS_PGM_LIST=" \
gss_jpclient/JP_FACECLIENTORDERCASHVW_NEW.sql \
gss_jpclient/copy1_JP_FACECLIENTORDERCASHVW.sql \
gss_client/copy2_JP_FACECLIENTORDERCASHVW.sql \
-\
"

# programs to run.
# -----------------------------
PGM_LIST="$GSS_PGM_LIST"



# ------------
# Main program
# ------------
for i in $PGM_LIST
do
    if [ "$i" != "-" ]
    then
        cd `dirname $PGM_DIR/$i`
        Run_SQL `basename $i`  >> $LOG 2>&1
     fi
done


[mod-EDIT - modified topic's title]

[Updated on: Mon, 23 July 2007 23:37] by Moderator

Report message to a moderator

Re: Rum parallel jobs [message #253360 is a reply to message #253357] Mon, 23 July 2007 10:46 Go to previous messageGo to next message
DreamzZ
Messages: 1666
Registered: May 2007
Location: Dreamzland
Senior Member
I guess script run single job at a time or you can use multiple scripts for multiple jobs at same time.
Re: Rum parallel jobs [message #253369 is a reply to message #253357] Mon, 23 July 2007 11:01 Go to previous messageGo to next message
Michel Cadot
Messages: 64151
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Something like (if there is "copy" in the script name then launch it in background):
for i in $PGM_LIST
do
    if [ "$i" != "-" ]
    then
        cd `dirname $PGM_DIR/$i`
        idx=`expr index $i 'copy'`
        if [ idx -ge 0 ]
        then
          Run_SQL `basename $i`  >> $LOG 2>&1 &
        else
          Run_SQL `basename $i`  >> $LOG 2>&1
        fi
     fi
done

Change it accordingly to your OS and shell.

Regards
Michel

[Updated on: Mon, 23 July 2007 11:01]

Report message to a moderator

Re: Rum parallel jobs [message #253372 is a reply to message #253369] Mon, 23 July 2007 11:12 Go to previous messageGo to next message
qasim845
Messages: 95
Registered: March 2007
Location: Philadelphia
Member

Thanks micheal I really appreciate your help. I just have last question in this thing Please.
Let's assume i have four copy jobs in the same script after running the create table script, i want to run first two copy jobs in parallel then second two jobs in parallel.

Much much appreciated your Help.
Thanks alot
Re: Rum parallel jobs [message #253374 is a reply to message #253372] Mon, 23 July 2007 11:23 Go to previous messageGo to next message
Michel Cadot
Messages: 64151
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Just add a new variable that you flip-flop and test, something like:
n=0
for i in $PGM_LIST
do
    if [ "$i" != "-" ]
    then
        cd `dirname $PGM_DIR/$i`
        idx=`expr index $i 'copy'`
        if [ $idx -ge 0 -a $n -eq 0 ]
        then
          Run_SQL `basename $i`  >> $LOG 2>&1 &
          n=1
        else
          Run_SQL `basename $i`  >> $LOG 2>&1
          n=0
        fi
     fi
done

Then the first copy will be in background and the next one in foregroung, then the following in background and the next in foreground...
You may have to add a "wait" command to be sure that the background process is completed before you start a new backgroung process.

Regards
Michel

[Updated on: Mon, 23 July 2007 12:43]

Report message to a moderator

Re: Rum parallel jobs [message #253422 is a reply to message #253374] Mon, 23 July 2007 16:41 Go to previous message
qasim845
Messages: 95
Registered: March 2007
Location: Philadelphia
Member

Thanks alot brother
Previous Topic: Getting core (merged)
Next Topic: Backward Compatibility and Core Dump.
Goto Forum:
  


Current Time: Fri Dec 09 13:31:24 CST 2016

Total time taken to generate the page: 0.28559 seconds