ESP Workload Automation

 View Only
Expand all | Collapse all

ESP Job flow based on Return Code

  • 1.  ESP Job flow based on Return Code

    Posted Aug 30, 2017 03:38 PM

    I have been trying to set up a job flow processing based on the exit code returned by a Unix job. 

     

    ESP Applictaion:

     

    UNIX_JOB MAINJOB
    REL (JOB1,JOB2)
    RUN DAILY
    SCRIPTNAME /usr/local/espr11/bin/SLEEP.txt
    AGENT %AGENT
    ENDJOB

    SUN_JOB CONDJOB
    RUN DAILY
    EXITCODE 1 SUCCESS
    RELEASE ADD(JOB1) COND(RC(0))
    RELEASE ADD(JOB2) COND(RC(1))
    SCRIPTNAME /usr/local/espr11/bin/FAILJOB.txt
    AGENT %AGENT
    ENDJOB

    UNIX_JOB JOB1
    RUN DAILY
    SCRIPTNAME /usr/local/espr11/bin/SLEEP.txt
    AGENT %AGENT
    ENDJOB

    UNIX_JOB JOB2
    RUN DAILY
    SCRIPTNAME /usr/local/espr11/bin/SLEEP.txt
    AGENT %AGENT
    ENDJOB

     

    JOB1 or JOB2 should run after the MAINJOB and also either one of the jobs should execute based on the exit code of the CONDJOB. 

     

    when the CONDJOB return code is '0' JOB1 should be executed and JOB2 should be bypassed.

    when the CONDJOB return code is '1' JOB2 should be executed and JOB1 should be bypassed.

     

    However, JOB2 is not bypassed or released when CONDJOB exit code is '1'.

     

    LTJ CONDJOB I
    JOB CONDJOB, MODEL MODEL1, OWNER NONE, 10 JOBS INDEXED, 10 MAX
    JOB25483 ON RDR AT 14.29.33 WED 30AUG2017, COMPLETED, CC 1, 0.0 MINS_EXEC, 0:0

     

    Job Name Job Qual ApplName Gen# Job Status Subappl Agent
    CONDJOB PRDTEST 33 COMPLETED AT 14.29 30 AUG DCDED
    JOB1 PRDTEST 33 WAITING, HC=1 DCDED --> Job is not released or bypassed. 
    JOB2 PRDTEST 33 COMPLETED AT 14.29 30 AUG DCDED
    MAINJOB PRDTEST 33 COMPLETED AT 14.29 30 AUG DCDED

     

    LTJ CONDJOB I
    JOB CONDJOB, MODEL MODEL1, OWNER NONE, 10 JOBS INDEXED, 10 MAX
    JOB25483 ON RDR AT 14.29.33 WED 30AUG2017, COMPLETED, CC 1, 0.0 MINS_EXEC, 0:0

     

    JOB JOB1

    PREDECESSORS
    MAINJOB(C)
    CONDJOB

    SUCCESSORS
    -- NONE



  • 2.  Re: ESP Job flow based on Return Code

    Posted Aug 30, 2017 04:10 PM

    Change the SUCCESS statement to include 0 

     

    SUN_JOB CONDJOB

      RUN DAILY

      EXITCODE 0-1 SUCCESS

      RELEASE ADD(JOB1) COND(RC(0))

      RELEASE ADD(JOB2) COND(RC(1))

      SCRIPTNAME /usr/local/espr11/bin/FAILJOB.txt

      AGENT %AGENT

    ENDJOB



  • 3.  Re: ESP Job flow based on Return Code

    Posted Aug 30, 2017 04:21 PM

    Hi Rick,

     

    Included exit code '0' to the success list, still no luck.

     

    UNIX_JOB CONDJOB --> Job ended with RC=1 
    RUN DAILY
    EXITCODE 0-1 SUCCESS
    RELEASE ADD(JOB1) COND(RC(0))
    RELEASE ADD(JOB2) COND(RC(1))
    SCRIPTNAME /usr/local/espr11/bin/FAILJOB.txt
    AGENT %AGENT
    ENDJOB

     

    Job Name Job Qual ApplName Gen# Job Status
    CONDJOB PRDTEST 44 COMPLETED AT 15.19 30 AU
    JOB1 PRDTEST 44 WAITING, HC=1
    JOB2 PRDTEST 44 COMPLETED AT 15.19 30 AU
    MAINJOB PRDTEST 44 COMPLETED AT 15.19 30 AU



  • 4.  Re: ESP Job flow based on Return Code
    Best Answer

    Posted Aug 30, 2017 04:36 PM

    Hi Guna, 

    Below is my example that works. I did this a while ago.  In this case both legs release a single job. If I remember correctly that is what makes it work. 

     

    UNIX_JOB JOBA
    RUN ANY
    AGENT AGENTU_01
    USER espadmin
    SCRIPTNAME /opt/scripts/testscripts/sleep.sh
    ARGS 5 2
    RELEASE ADD(JOBB) COND(RC(1))
    RELEASE ADD(JOBC) COND(RC(2))
    exitcode 1-2 success
    ENDJOB

    UNIX_JOB JOBB
    RUN ANY
    AGENT AGENTU_01
    USER espadmin
    SCRIPTNAME /opt/scripts/testscripts/sleep.sh
    ARGS 300
    exitcode 1-2 success
    ENDJOB

     

    UNIX_JOB JOBC
    RUN ANY
    AGENT AGENTU_01
    USER espadmin
    SCRIPTNAME /opt/scripts/testscripts/sleep.sh
    ARGS 30
    exitcode 1-2 success
    RELEASE (JOBD)
    ENDJOB

    UNIX_JOB JOBD
    RUN ANY
    AGENT AGENTU_01
    USER espadmin
    SCRIPTNAME /opt/scripts/testscripts/sleep.sh
    exitcode 1-2 success
    ARGS 30
    ENDJOB

     

    Don



  • 5.  Re: ESP Job flow based on Return Code

    Posted Aug 30, 2017 04:37 PM

    I tried my example without the last dummy job and it worked. 



  • 6.  Re: ESP Job flow based on Return Code

    Posted Aug 30, 2017 04:49 PM

    Hi Don,

     

    Thanks for the details, here in your sample code we could see JOBB & JOBC does not have any predecessor except JOBA. The same kind of setup works when I remove the "REL (JOB1,JOB2)" statement from the MAINJOB. However when another predecessor(MAINJOB) is added to the JOB1, JOB2 the job seems to stay on WAIT status. 

     

     Job Name Job Qual ApplName Gen# Job Status

    MAINJOB PRDTEST 45 COMPLETED AT 15.42 30 AUG 
    CONDJOB PRDTEST 45 COMPLETED AT 15.42 30 AUG
    JOB1 PRDTEST 45 BYPASSED
    JOB2 PRDTEST 45 COMPLETED AT 15.42 30 AUG

     



  • 7.  Re: ESP Job flow based on Return Code

    Posted Aug 30, 2017 05:30 PM

    Hi Guna, 

    I have the same issue if I schedule it this way...... I am still thinking... 



  • 8.  Re: ESP Job flow based on Return Code

    Posted Aug 30, 2017 05:38 PM

    NOTE:

    I think the issue may be caused by the BYPASS/NOBYPASS option of the conditional release statement. The default is BYPASS until it hits an intersecting stream. BUT in this case the intersecting stream is right away. 



  • 9.  Re: ESP Job flow based on Return Code

    Posted Aug 30, 2017 05:42 PM

    This option could be done with REQUEST commands to request the job or stream of jobs. It is more complex and would need to be tested carefully.  The key to making this work is adding a reldelay in the next dummy job so the command has time to process. 



  • 10.  Re: ESP Job flow based on Return Code

    Posted Sep 05, 2017 02:10 PM

    Hi Don,

     

    Do you mean adding a Link Process to be selected based on the return code of a CONDJOB and bypass selected jobs based on the exit code, 



  • 11.  Re: ESP Job flow based on Return Code

    Posted Aug 31, 2017 08:53 AM

    Change the RELEASE statement in MAINJOB to release CONDJOB

     

    Current:

    UNIX_JOB MAINJOB
    REL (JOB1,JOB2)
    RUN DAILY
    SCRIPTNAME /usr/local/espr11/bin/SLEEP.txt
    AGENT %AGENT
    ENDJOB

     

    Proposed:

    UNIX_JOB MAINJOB
    REL (CONDJOB)
    RUN DAILY
    SCRIPTNAME /usr/local/espr11/bin/SLEEP.txt
    AGENT %AGENT
    ENDJOB