Unix master shell script to run jobs in parallel with dependency

I need a master shell script which would call the following shell scripts as per below order. Kindly note that if any shell script fails then the master shell script should abort.
Level 1     PRODUCTS
     SP_ROST_DLY_STG_lD
     SP_ROST_DLY_ITG_lD
After Level 1 completes run below two shell scripts in parallel:
Level 2     SP_IDL_EDGE_CON_POSTN_STG_Ld ,     SP_IDL_EDGE_ACCT_POSTN_STG_LD
After Level 2 completes run below shell scripts as per the seqeunce and in parallel:
Level 3     SP_IDL_EDGE_ACCT_STG_LD ,     SP_IDL_EDGE_CONT_STG_LD
     SP_IDL_EDGE_ACCT_STG_VAL ,     SP_IDL_EDGE_CONT_STG_VAL
     SP_IDL_EDGE_ACCT_ITG_Ld ,     SP_IDL_EDGE_CON_ITG_Ld
After Level 3 completes run below shell scripts as per the seqeunce and in parallel:
Level 4     SP_IDL_EDGE_CONT_POSTN_ITG_LD ,     SP_IDL_EDGE_VISITS_LD
     SP_IDL_EDGE_ACCT_POSTN_ITG_LD ,     SP_IDL_EDGE_VISITS_DTL_LD

can i avoid using set -e and use some other method so that if there is an error in previous job then the next job is not triggered.Sure, but it is ugly.
The below is not the only way to do this...
Wrap every place you start another script with:
$ if ! MYSCRIPT; then
    echo Script MYSCRIPT failed. >&2
    exit 1
fibut the wrapper for parallel scripts is even worse:
$ MYSCRIPT &
$ MYSCRIPT_JOBNO=$!
$ MYSCRIPT2 &
$ MYSCRIPT2_JOBNO=$!
$ MYSCRIPT_STATUS=`wait ${MYSCRIPT_JOBNO}`
$ if [ ${MYSCRIPT_STATUS} -ne 0 ]; then
    echo Script MYSCRIPT failed. >&2
    exit 1
fi
$ MYSCRIPT2_STATUS=`wait ${MYSCRIPT2_JOBNO}`
$ if [ ${MYSCRIPT2_STATUS} -ne 0 ]; then
    echo Script MYSCRIPT2 failed. >&2
    exit 1
fi
...Now, doesn't a simple 'set -e' look much better?

Similar Messages

  • Sample shell scripts to run workbooks

    Does anybody have some sample shell scripts to run the workbooks?

    Your Schedule workbooks thru command line thread contains answers.

  • Rwcgi60 on UNIX needs shell script ?

    I am trying out Reports 6i on a Linux box.
    Using Apache Webserver, I have mapped all the virtual directories with execute permission.
    When I call rwcgi60 through the browser, I get the following output
    <HTML>
    <HEAD>
    <TITLE></TITLE>
    </HEAD>
    <BODY>
    <CENTER><H1>
    </CENTER></H1>
    <BR></BODY>
    </HTML>
    But when i call a shell script (which in turn calls rwcgi60) through the browser, i get some output.
    The shell script exports all the environment specific to Oracle Reports and calls rwcgi60.
    Is the CGI intended to be called from a script file ? If no, what other configuration is necessary ?
    Thanks.

    I am having exactly the same problem on Solaris. The information I have shoehorned out of support so far is that you do need a shell script to make this work. I have followed these instructions but am still having problems. The document which details this bug is unpublished by Oracle so I only got extracts. Detailed below.....if you do have success with this please let me know as I am tearing my hair out.
    REPORTS60_SERVER
    1. The REPORTS60_SERVER file is located in your Oracle_Home and is used to
    start the Report Server.
    2. You may need to modify this file for variables such as DISPLAY, TNS_ADMIN
    and the REPORTS60_PATH to fit your environment. @Also, please refer to
    @Note: 111548.1 for setting up the TNSNAMES.ORA file.
    3. If you are not using a WebDB Listener, you can delete the section which
    stops and starts it. However, make sure you have started up your Webserver
    Listener.
    4. Once this file has been modified, the command to execute it is:
    reports60_server start
    Shell Script (RUNREP.SH)
    1. You will need to create a shell script to run RWCGI60. This shell will then
    be called from RUNREP.HTM file. You can name it anything (the example is
    called runrep.sh) and needs to include the following:
    #!/bin/sh (or which ever shell you want to use)
    - ORACLE_HOME="/u03/app/oracle/product/dev6i"; export ORACLE_HOME
    - TNS_ADMIN="/u03/app/oracle/product/dev6i/network/admin"; export
    TNS_ADMIN
    - exec /u03/app/oracle/product/dev6i/tools/web60/cgi/rwcgi60
    2. You will need to redefine the ORACLE_HOME and TNS_ADMIN due to BUG:1201156.
    3. This script can be located anywhere as far as the Webserver
    Listener is
    concerned. However, the best place would be in the ORACLE_HOME/tools/web60/
    cgi directory for which we already have a virtual name defined in the
    listener configuration file.
    RUNREP.HTM
    1. The RUNREP.HTM file is located in the ORACLE_HOME/tools/web60/html
    directory.
    2. You will need to modify this file due to the above mentioned Bug.
    Go to the function called runReport( ) and for the var cgiexe = "rwcgi60",
    replace it with the above shell script.
    Example: var cgiexe = "runrep.sh"
    3. Next, modify the port number for the Webserver. This file assumes that you
    will be using the WebDB listener and is installed on port 8080 (by default).
    You will need to find the following and change it to the correct port
    number:
    <td><input TYPE="TEXT" NAME="WEBPORT" SIZE="4" VALUE="8080"></td>
    Change the Port Number to the one your WebServer Listener is on, such as:
    7777.
    After doing all of the above, you are ready to run a report on the web using
    CGI implementation. From the browser run the following URL:
    http://your_machine_name:listener_port#/virtual_dir_for_cgi/runrep.htm
    This brings up a Template for you to provide the report name. Also change the
    parameter values here for the userid/password, port#, and reports_server.

  • Using a UNIX shell script to run a Java program (packaged in a JAR)

    Hi,
    I have an application (very small) that connects to our database. It needs to run in our UNIX environment so I've been working on a shell script to set the class path and call the JAR file. I'm not making a lot of progress on my own. I've attached the KSH (korn shell script) file code.
    Thanks in advance to anyone who knows how to set the class path and / or call the JAR file.
    loggedinuser="$(whoami)"
    CFG_DIR="`dirname $0`"
    EXIT_STATUS=${SUCCESS}
    export PATH=/opt/java1.3/bin:$PATH
    OLDDIR="`pwd`"
    cd $PLCS_ROOT_DIR
    java -classpath $
    EXIT_STATUS=$?
    cd $OLDDIR
    echo $EXIT_STATUS
    exit $EXIT_STATUS

    Hi,
    I have an application (very small) that connects to
    our database. It needs to run in our UNIX environment
    so I've been working on a shell script to set the
    class path and call the JAR file.
    #!/bin/sh
    exec /your/path/to/java -cp your:class:paths:here -MoreJvmOptionsHere your.package.and.YourClass "$@"Store this is a file of any name, e.g. yuckiduck, and then change the persmissions to executechmod a+x yuckiduckThe exec makes sure the shell used to run the script does not hang around until that java program finishes. While this is only a minor thing, it is nevertheless infinite waste, because it does use some resources but the return on that investment is 0.
    CFG_DIR="`dirname $0`"You would like to fetch the directory of the installation out of $0. This breaks as soon as someone makes a (soft) link in some other directory to this script and calls it by its soft linked name. Your best bet if you don't know a lot of script programming is to hardcode CFG_DIR.
    OLDDIR="`pwd`"
    cd $PLCS_ROOT_DIRVery bad technique in UNIX. UNIX supports the notion of a "current directory". If your user calls this program in a certain directory, you should assume that (s)he does this on purpose. Making your application dependent on a start in a certain directory ignores the very helpful concept of 'current directory' and is therefore a bug.
    cd $OLDDIRThis has no effect at all because it only affects the next two lines of code and nothing else. These two lines, however, don't depend on the current directory. In particular this (as the cd above) does not change the current directory for the interactive shell your user is working in.
    echo $EXIT_STATUS
    exit $EXIT_STATUSEchoing the exit status is an interesting idea, but if you don't do this for a very specific purpose, I recommend not to do this for the simple reason that no other UNIX program does it.
    Harald.

  • Shell Script to grep Job File name and Log File name from crontab -l

    Hello,
    I am new to shell scripting. I need to write a shell script where i can grep the name of file ie. .sh file and log file from crontab -l.
    #51 18 * * * /home/oracle/refresh/refresh_ug634.sh > /home/oracle/refresh/refresh_ug634.sh.log 2>&1
    #40 17 * * * /home/oracle/refresh/refresh_ux634.sh > /home/oracle/refresh/refresh_ux634.sh.log 2>&1
    In crontab -l, there are many jobs, i need to grep job name like 'refresh_ug634.sh' and corresponding log name like 'refresh_ug634.sh.log '.
    I am thinking of making a universal script that can grep job name, log name and hostname for one server.
    Then, suppose i modify the refresh_ug634.sh script and call that universal script and echo those values when the script gets executed.
    Please can anyone help.
    All i need to do is have footer in all the scripts running in crontab in one server.
    job file name
    log file name
    hostname
    Please suggest if any better solution. Thanks.

    957704 wrote:
    I need help how to grep that information from crontab -l
    Please can you provide some insight how to grep that shell script name from list of crontab -l jobs
    crontab -l > cron.log -- exporting the contents to a file
    cat cron.log|grep something -- need some commands to grep that infoYou are missing the point. This forum is for discussion of SQL and PL/SQL questions. What does your question have to do with SQL or PL/SQL.
    It's like you just walked into a hardware store and asked where they keep the fresh produce.
    I will point out one thing about your question. You are assuming every entry in the crontab has exactly the same format. consider this crontab:
    #=========================================================================
    # NOTE:  If this is on a clustered environment, all changes to this crontab
    #         must be replicated on all other nodes of the cluster!
    # minute        (0 thru 59)
    # hour          (0 thru 23)
    # day-of-month  (1 thru 31)
    # month         (1 thru 12)
    # weekday       (0 thru 6, sunday thru saturday)
    # command
    #=========================================================================
    00 01 1-2 * 1,3,5,7 /u01/scripts/myscript01  5 orcl  dev
    00 04 * * * /u01/scripts/myscript02 hr 365 >/u01/logs/myscript2.lis
    00 6 * * * /u01/scripts/myscript03  >/u01/logs/myscript3.lisThe variations are endless.
    When you get to an appropriate forum (this on is not it) it will be helpful to explain your business requirement, not just your proposed technical solution.

  • Sample shell script - to run procedures and shell script

    Hi ,
    I would like run some procedures in one shell script which passing parameters as username/password@dbname.
    1. Execute proce1
    2.Execute proce3
    3.Execute proc4
    Can you please give some script/idea how we will create shell script . I am using SunSolaris Unix operating system.I would appreciate your help.
    Regards,
    Clark

    user10818198 wrote:
    I would like run some procedures in one shell script which passing parameters as username/password@dbname.
    1. Execute proce1
    2.Execute proce3
    3.Execute proc4
    At a very basic level, based on the information you have provided, your shell script would be something like this:
    sqlplus /nolog <<EOF
    connect username/password@dbname
    exec proce1;
    exec proce2;
    exec proce3;
    exit
    EOFBesides this, you could:
    (1) Add the shebang at the top, to specify the shell you are using, e.g. #!/bin/ksh for the Korn shell etc.
    (2) Ensure that "sqlplus" is recognized by the shell, by maybe running an "ora_env.sh" script that sets Oracle parameters. More likely, if you are using this Unix account for interaction with Oracle, then you may want to add the Oracle parameter information in your .profile or .bash_profile or .csh_profile etc. in the home directory.
    (3) Run a few sqlplus commands right before calling those stored procedures, if needed. For example, if you want to exit from sqlplus (and Oracle) if an error occurs while executing any procedure, then add this -
    whenever sqlerror exit 1Thus your script becomes:
    #!/bin/ksh
    # Ensure that Oracle parameters are set by this point
    sqlplus /nolog <<EOF
    connect username/password@dbname
    whenever sqlerror exit 1
    exec proce1;
    exec proce2;
    exec proce3;
    exit
    EOF(There are other settings as well; it really depends on your requirements.)
    Can you please give some script/idea how we will create shell script . I am using SunSolaris Unix operating system.
    How to create a shell script ? Well,
    (1) Save the commands shown above in a file, using your favorite text editor. Name the file "my_script.sh" or "<a_better_name>.sh" etc. (or maybe ".ksh" for the Korn shell - it's just a best practice, the shell doesn't really care.)
    (2) Make your script executable, like so -
    $ chmod 744 myscript.sh(3) And then execute it -
    $ ./myscript.sh- You could also execute the script in the current shell (as against a child shell) by doing this after Step (1):
    $ . myscript.shHope that helps.
    If there are specific questions, then post them here.
    isotope

  • Shell script for running obiee 11g services in linux

    Hi
    We have a requirement to create a shell script inorder to run OBIEE 11G services in Linux OS. It would be very helpful and greatly appreciated if any pointer(s)/documentation on this is provided.
    Thanks

    we had run the scripts using nohup "nohup ./startWeblogicServer.sh &" and reopened putty to run other nodemanager and opmnctl scripts, now everything has started and working fine.
    Thanks all..

  • Need Power shell script to run on all databases.

    Hi,
    I have a stored procedure to generate report, using power shell script want to get all databases, run stored procedure on each database and generate the results as .csv file, output the file with database name (place it on directory) and  email .csv
    file.
    looking for script, can any one help pls?
    Naveen| Press Yes if the post is useful.

    Can you please share with me the codes
    Naveen| Press Yes if the post is useful.
    Dear N_14
    You can have a look on the followings
    http://www.csharp-station.com/Tutorial/AdoDotNet/lesson07
    http://www.codeproject.com/Articles/415732/Reading-and-Writing-CSV-Files-in-Csharp
    https://msdn.microsoft.com/en-us/library/system.net.mail.mailmessage%28v=vs.110%29.aspx
    Best Regards
    mintssoul

  • Automator workflow "run shell script" keeps running. How to stop?

    Because i want two instances of dropbox running simultaneously on my Mac, I set up a small automator workflow application. The workflow consist of a simple shell script:
    Or in text:
    bash
    HOME=$HOME/Dropbox-quivertree /Applications/Dropbox.app/Contents/MacOS/Dropbox &
    The problem is that once the application runs, or i execute the script from within automator, it just keeps running (i get the little cog in my menubar). Anybody have an idea how to automatically stop after it has launched dropbox?
    Thanks!
    Kim

    I do not have dropbox on my computer, so I tested using the Calculator application. The solution proposed by Mattis S.F. does work, but his explanation does not hold true in my case. Initially, I successfully tried
    HOME=$HOME/Dropbox-quivertree nohup /Applications/Calculator.app/Contents/MacOS/Calculator >/dev/null 2>&1 &
    If I remove the “nohup”, the result does not change. Removal of the “/dev/null 2>&1”, however, results in the same problem originally described by Kim van der Leeuw. My guess is the background process has stdout and stderr redirected by default back to the automator. When redirected to /dev/null, the automator no longer waits for the background process to complete. To summarize, change
    HOME=$HOME/Dropbox-quivertree /Applications/Dropbox.app/Contents/MacOS/Dropbox &
    to
    HOME=$HOME/Dropbox-quivertree /Applications/Dropbox.app/Contents/MacOS/Dropbox >/dev/null 2>&1 &

  • Power shell script to run a Resuable workflow.

    Hi,
    We came across a scenario where we want to run a resuable workflow on all List items in a list. I am not sure if this can be acheived through power shell. Can any one please help me to run reusable workflows through power shell script on list items.
    Thanks,
    Sandy

    Hello,
    Recently i executed below script for my VS workflow on list items, you can also try same on reusable WF.
    Basically you need to use "WorkFlowManager" and "WorkFlowAssociations " to find WF on list and then execute it.
    http://www.mysharepointadventures.com/2012/06/start-a-workflow-using-powershell/
    http://www.thesysadminhimself.com/2013/09/sharepoint-start-workflow-all-items-powershell.html
    Hemendra:Yesterday is just a memory,Tomorrow we may never see
    Please remember to mark the replies as answers if they help and unmark them if they provide no help

  • LoginHook Shell Script not running?

    I have a very simple login shell script (open http://pathtowebsite.local) that I have set as a LoginHook. When running the script from the Terminal, it opens the website, as expected. However, on login it appears that something happens, the menu bar flashes and disappears until you click on something, but the website doesn't open. The permissions are set properly, and it is executable. The script is located in the global /Library folder in a folder I created called Management, though I also tried putting it in the /Users/Shared directory in case it was an access issue.
    Any ideas on what I might do to resolve this issue? I can't seem to get it to actually kick off at user login like it should.

    The LoginHook environment is minimum. There is NO PATH
    pwd: /
    id -a: uid=0(root)
    gid=0(wheel)
    egid=80(admin)
    groups=0(wheel),
    1(daemon),
    2(kmem),
    8(procview),
    29(certusers),
    3(sys),
    9(procmod),
    4(tty),
    5(operator),
    80(admin),
    20(staff)
    $1: thelogin_person'susername
    printenv:
    PWD=/
    SHLVL=1
    SECURITYSESSIONID=449a3aa0
    _=/usr/bin/printenv
    Notice, no PATH, no USER environment variables, just about nothing as an environment.
    So there is no way for the LoginHook to find the 'open' command.
    Try changing your script to /usr/bin/open

  • Shell script to run PL/SQL Program

    hai,
    i have problem in returning values from PL/SQL procedyre back to Shell script which calls the procdure.can anyone please suggest a model shell script to handle this
    Thankyou

    SQL> create or replace function disp_mess
      2  return varchar2 is
      3  begin
      4     return('Hello World');
      5  end;
      6  /
    Function created.
    SQL> select disp_mess from dual;
    DISP_MESS
    Hello World
    SQL> exit
    Disconnected from Oracle8i Enterprise Edition Release 8.1.7.4.0 - Production
    With the Partitioning option
    JServer Release 8.1.7.4.0 - Production
    $ cat disp_mess.sh
    MESS=`sqlplus -s scott/tiger << !
    set head off
    set pages 0
    select disp_mess from dual;
    exit
    ! `
    echo $MESS
    $ disp_mess.sh
    Hello World
    $Paul

  • Shell Script- To FTP the latest file with the date stamp

    I have a Solaris 10 based system, where it generate some application files (multiple) in XML format and the file name comprises of the current date.
    File Format is as follows;
    CX-FIL-20070624000000-2-8452536d-000133.xml
    Where 20070624 repesents the curent date of the file
    I want to FTP these files to another server (Solaris 10 based Sun Machine) by comparing the file name with the current date.
    Please let me know how I can do this by using a shell script.

    Assuming you want to ftp the files with today's datestamp, you could match the files you want like so:
    CX-FIL-`/bin/date +"%Y%m%d"`*
    Use that in your script to generate the file list to be transferred...
    -Rob

  • Shell script to run against 1000s dbs

    what's should be the things to put in this scripts, like how to connect to different server & connect /as sysdba ; and run .sql ? just trying to understand how these kind of scripts work?

    #!/bin/sh
    #Pull all entries from your tnsnames.ora file, skipping lines with # ( )
    #SQLPLUS to each as sys and show the current date
    #This assumes that your SYS password is the same on all instances.
    for tns_name in `grep -v -E '#|\(|\)' $TNS_ADMIN/tnsnames.ora | cut -f 1 -d ' '`
    do
    sqlplus -s sys/sys_pwd@${tns_name} as sysdba <<EOF
    set head off pages 0 verify off
    select sysdate from dual;
    exit;
    EOF
    done
    Hope this helps.

  • Sqlplus and unix (bash) shell scripting

    Hi,
    I'm extracting some information from a DB and then "spooling" it to a file. So far so good.
    The problem is that the records I get are not like what they look like when I run the stuff in sqlplus. Instead, the spooled file has alot of weird spaces and tabs in between and does not properly separate between the different rows.
    Does anyone have any tips on how to do this?
    Note: The datatype of the field I'm retrieving is "long". I've set linesize, pagesize and long to 1000.

    Hi!
    Try also to change SQL*Plus settings, i.e. SET LINESIZE 1000 (or whatever the most long line of your report could be), then TRIMSPOOL ON, TRIMOUT ON.
    Regards,
    Andrew Velitchko
    BrainBench MVP for Developer/2000
    http://www.brainbench.com

Maybe you are looking for

  • Itunes/Ipod with multiple Vista users - Problem

    To set the stage - new Vista PC, shared by the family - so I set up individual ID's (thought that would prevent my kids from corrupting our stuff). Oh, and thought Vista was compatible......... On the admin account, which is where the iTunes Library

  • How to position the cursor in a text

    I there a better way to position the cursor in a text portion other than trying it several times until the OS picks the right space? I know the iPad has a good way to do it by zooming in. Or is RIM working on it.....

  • I bought the sonicimpact about 1 yr ago and my new slim ipod doesn't fit; h

    see above; there are no docking holders that fit the slim nano. help.

  • No supported calendar application can be found.....

    Even though I don't have a supported calendar, I still get errors stating that "iTunes cannot sync your calendar because there was an error merging the data". Can someone fill me in here as to what may be happening? Since I posted here last I haven't

  • Remove Send-As for domain admin groups

    With referring to below link. http://social.technet.microsoft.com/Forums/exchange/en-US/d2e97e64-536a-4c46-8e57-e0ac6a4ad64e/how-do-i-remove-domain-admins-send-as-settings-for-all-users?forum=exchangesvradminlegacy The solution work perfectly for nor