Automic Community

Expand all | Collapse all

Windows job and job status '&STATUS'

Jump to Best Answer
  • 1.  Windows job and job status '&STATUS'

    Posted 11-05-2019 07:54 PM
    I am trying to change the way we are running Windows jobs by coding combinations of Pre-Process, Process and Post Processing tabs.
    I can run jobs and for the most part is working fine.
    The issue I am having is when a job fails, the issue is corrected and the failed job is restarted the job 'STATUS' from failure is retained in restart and the job fails again with same error (job should end successfully).

    I have tried many combinations of SET / RSET / PSET for '&STATUS' on both Pre-Process and Process tab (job status is controlled with MODIFY on job Post-Process tab) with little success.

    Make sense?  Anyone have ideas on where or what command to control with?
    I do not want to set static variable to control as there are 100s of these jobs and to me this should be dynamic.
    I think I am missing something simple....

    Appreciate input.
    Fred Shindle


    ------------------------------
    IT Enterprise System Administrator
    Idaho Power Company
    ------------------------------


  • 2.  RE: Windows job and job status '&STATUS'
    Best Answer

    Posted 11-06-2019 02:03 AM
    Hi Fred

    Are variables impacting the behaviour of your script? They might impact the environment your restarting job meets.

    Example. Create a SCRI object with the below content:
    :PSET &STATUS# = &STATUS#
    :PRINT &STATUS#
    :PSET &STATUS# = 'FAILURE'
    :PRINT &STATUS#

    Execute it. You will see an empty line and a line saying "FAILURE". Now restart the script - you will see two "FAILURE" lines.

    Regards
    Joel

    ------------------------------
    Swisscom Automation Engineer & PE Membership Creator

    Entfessle mehr Automic Wissen mehr Automic Tools
    https://membership.philippelmer.com/
    ------------------------------



  • 3.  RE: Windows job and job status '&STATUS'

    Posted 11-06-2019 11:53 AM

    Joel,

    Thanks for reply and not sure I fully understand reply.

     

    I use the print statements to display for troubleshooting and to have in normal/scheduled jobs.

     

    You make a statement about 'They might impact the environment your restarting job meets.'

     

    I believe this is my issue as they are impacting but cannot figure out why on a restart 'values' are retained from prior failure.  Makes no sense from any batch perspective.

    A restarted job should have RC/status flushed and be new.

     

    Correct?

     






  • 4.  RE: Windows job and job status '&STATUS'

    Posted 11-06-2019 02:09 PM
    No matter which way I test this:
    * fail, correct, rerun
    * run successfully, cause error, restart

    The job always keep the previous run's status.
    I have used all set (SET, RSET & PSET) on pre-process and process tabs with same results.

    ------------------------------
    IT Enterprise System Administrator
    Idaho Power Company
    ------------------------------



  • 5.  RE: Windows job and job status '&STATUS'

    Posted 11-07-2019 01:15 AM
    The behaviour of a job can be impacted by AE script. The RC information of the previous run is usually flushed as you would expect. However in AE script you might have some logic that a job behaves differently when it gets restarted. So without being able to see the pre/post/process code of the job it's just an idea.

    The job itself runs successfully after a restart, but Automic doesn't recognize it, correct? Then I would check the postprocess on the job object and the postconditions of that task on the workflow.

    ------------------------------
    Swisscom Automation Engineer & PE Membership Creator

    Entfessle mehr Automic Wissen mehr Automic Tools
    https://membership.philippelmer.com/
    ------------------------------



  • 6.  RE: Windows job and job status '&STATUS'

    Posted 11-07-2019 03:46 PM

    Joel,

    Appreciate replies.

    Also to note I am trying to combine 2 jobs that used to run in a workflow that acted as a single job, the jobP has a 'trigger' job and a 'done' job that initiated a distributed script.  The trigger job would launch and the done job would monitor for the update of a file that has completion/RC code.  This was written by UC4 sometime ago as a solution when we converted.

     

     

    I am trying to combine those 2 jobs into single job with tabs as below.

    This works fine for triggering the external script, the issue is only for a restart and retaining the &STATUS code from first run.

    Process Tab

    !!! step005 !!!

    cd D:\Directory\Logs

    del Script_Name.done

     

    !!! step010 !!!

    copy empty.txt Script_Name.done

     

    !!! step020 !!!

    :set &date = sys_date("YYYY-MM-DD")

    :set &time = sys_time("HH:MM:SS")

     

    !!! step030 !!!

    echo '&date &time Triggered' >> D:\Directory\Logs\Script_Name.trigger

     

    Post Process Tab

    :SET &FOUND = 'FALSE'

     

    :WHILE &FOUND = 'FALSE'

    :  SET &HND#=PREP_PROCESS_FILE(WIN_AgentName,"D:\Directory\Logs\Script_Name.done","*return code*")

    :  PROCESS &HND#

    :     SET &LINE#=GET_PROCESS_LINE(&HND#)

    :     PRINT &LINE#

    :     SET &FOUND = 'TRUE'

    :     SET &CODE = STR_FIND(&LINE#,'code',1)

    :     SET &CODE = ADD(&CODE,7)

    :     SET &RET = STR_CUT(&LINE#,&CODE)

    :     PRINT 'RC=&ret'

    :     IF &RET <> '0'

    :       SET &END_STATUS = '100'

    :       RSET &STATUS# = &END_STATUS

    :     ELSE

    :       SET &END_STATUS = '0'

    :       RSET &STATUS# = &END_STATUS

    :     ENDIF

    :  ENDPROCESS

    :  CLOSE_PROCESS &HND#

    :  wait 1

    :ENDWHILE

    !

    ! Modify status of job if not equal to 0 at exit.

    !

    :PRINT 'Status of job is &STATUS#'

    !

    :IF &STATUS# <> '0'

    :    MODIFY_STATE RETCODE=&STATUS#

    :ENDIF

     






  • 7.  RE: Windows job and job status '&STATUS'

    Posted 11-07-2019 04:33 PM
    Hi Fred


    Ok, I would focus on the postprocess.

    :RSET will retain the STATUS# value when the job is restarted. It's sufficient to use :SET here.

    This part:

    :IF &STATUS# <> '0'
    :    MODIFY_STATE RETCODE=&STATUS#

    :ENDIF

    Does not need any if-condition check. The result will be the same.
    :MODIFY_STATE RETCODE=&STATUS#

    If I interpret the script right, you add a line to the trigger-file that triggers an external process (which watches the file for changed content or updated modified-timestamp) and then you wait in the done-file for a "return code" string to appear. That seems all to be fine.

    Can you post a post process report of a restarted job that does not act the way you expect?

    Greetings to Idaho. Lovely state, been there some years ago.



    ------------------------------
    Swisscom Automation Engineer & PE Membership Creator

    Entfessle mehr Automic Wissen mehr Automic Tools
    https://membership.philippelmer.com/
    ------------------------------



  • 8.  RE: Windows job and job status '&STATUS'

    Posted 11-07-2019 04:41 PM

    Thanks Joel,

    I have to step away but will test this first thing, greatly appreciated.

     

    Yes Idaho is nice...being overrun with people right now...changing a lot.

    Where are you from?

     






  • 9.  RE: Windows job and job status '&STATUS'

    Posted 11-07-2019 04:43 PM

    And yes you understand the process exactly.

     






  • 10.  RE: Windows job and job status '&STATUS'

    Posted 11-08-2019 01:20 PM

    Joel,

    Thanks again for information, I have changed and tested successfully, very good.

    But...I am confused, this is a section out of the book.  What you have told me and I have tested successfully does not align with this...I am confused but not the first time the book has been incorrect.

     

     

     






  • 11.  RE: Windows job and job status '&STATUS'

    Posted 11-08-2019 01:51 PM
    Hi Fred

    To answer the question from your last post - I'm from Switzerland ;-). So mountain and snow as well hehe.

    The referred documentation is correct, :RSET will, when the job does NOT run as a "restart", register a value as an object variable. If the job is being restarted, the :RSET behaves like a normal :SET and will overwrite the existing object variable value. Object variables persist when the object is restarted. At least that's what I remember, I do not often use such mechanisms.

    ------------------------------
    Swisscom Automation Engineer & PE Membership Creator

    Entfessle mehr Automic Wissen mehr Automic Tools
    https://membership.philippelmer.com/
    ------------------------------



  • 12.  RE: Windows job and job status '&STATUS'

    Posted 11-09-2019 03:11 PM

    Well...the behavior is odd but is what it is...

     

    The :SET is working and again appreciate the information, I have been trying this every which away with no success.

    The behavior without the :RSET is what I was after.

     

    I hear you have some stellar skiing, resorts and good folks over there.  A co-worker was over there last year...I have always wanted to do some skiing there.

     

    Thanks again for clearing this up.