Automic Workload Automation

Expand all | Collapse all

How to execute a job more than the once post-conditions else allows

Legacy User

Legacy UserMar 03, 2015 09:35 AM

  • 1.  How to execute a job more than the once post-conditions else allows

    Posted Feb 26, 2015 05:31 AM
    New to AE - I have a job that I want to restart if it gives other than an OK return code - 
    The actual job is dependent on a file being there - its usually there @ 0900 when the job is scheduled to start but as it is user driven it is sometimes late so the job fails - I have used the post condition tab in the task properties to restart the task after 15 minutes on anything but an OK status. - this is OK but it allows only a single restart or a continuous cycle.
    The business wants a 2nd retry after a further 15 minutes before the job abends and generates the automated alerts for the failure.
    We are trying to get the basic functionality to do most of our batch scheduling needs - we do not want to complicate things by using scripts.
    Has anyone got any idea's on how I can do this. 


  • 2.  How to execute a job more than the once post-conditions else allows

    Posted Feb 26, 2015 09:42 AM
    IanFindon611036 
    You can use the Pre-defined system variable &$RESTART_COUNT# in a USER DEFINED Condition in the post process to control how many times the object is restarted (i.e. IF &$RESTART_COUNT# <2).
    See attached screen print for example.

    kiu851k2qy0g.jpghttps://us.v-cdn.net/5019921/uploads/editor/t8/kiu851k2qy0g.jpg" width="747">


  • 3.  How to execute a job more than the once post-conditions else allows

    Posted Feb 26, 2015 11:34 AM
    Thanks Jessie - I'll test in our development client - one thing should the "RESTART TASK" be as above "ALWAYS(curly arrow)" or should I change to "ONCE" instead.

    Ian.


  • 4.  How to execute a job more than the once post-conditions else allows

    Posted Feb 26, 2015 11:40 AM
    You can keep the RESTART TASK as "always(curly arrow)" as the &RESTART_COUNT# <x variable controls the restart task.


  • 5.  How to execute a job more than the once post-conditions else allows

    Posted Feb 27, 2015 05:32 AM
    Hi Ian,

    In theory you should check to see if the file is there before attempting to process this.

    This can be done using the EVENT FILE object, which will look at the directory and only end once the file is present & has been stable for x number of minutes.

    Thanks,
    Chris


  • 6.  How to execute a job more than the once post-conditions else allows

    Posted Feb 27, 2015 08:27 AM
    Jesse - Thanks once again - that answers that question. Not had the chance to test yet but will do in the next couple of days.

    Chris, thanks for your input - we are using pre-conditions in some jobs to check if a file exists - However, in this instance we don't require this but need the job to alert in some way if the file isn't there within a certain timescale.


  • 7.  How to execute a job more than the once post-conditions else allows

    Posted Mar 03, 2015 07:05 AM
    Jesse - successfully tested the solution and it was what we want- now in production - Many Thanks for your help.


  • 8.  How to execute a job more than the once post-conditions else allows

    Posted Mar 03, 2015 09:35 AM
    >@</p>Ian Findon" 
    Great! Glad to help.


  • 9.  How to execute a job more than the once post-conditions else allows

    Posted Mar 06, 2015 03:30 PM
    Hey Ian, I have to give a +1 to what Chris was saying.  IMO the best method for this would be to have your process have a file event looking for the existence of the file before running your next process. If you want to alert that the file isn't there by a specific time, you can use the runtime tab in the event to execute a call object to send an email to whomever or even have a visual alert on the screen for those watching the system. This also makes it easier to track real failures with your process instead of assuming the failure is due to the file not being available. 


  • 10.  How to execute a job more than the once post-conditions else allows

    Posted Mar 16, 2015 11:09 AM
    >@</p>Jim Griffith" 

    Hi Jim, understand that and we explained it to the user - but in this instance that's the way the Business wants it to work.


  • 11.  How to execute a job more than the once post-conditions else allows

    Posted Oct 19, 2016 08:38 AM
    jesse.getzie, I am trying to do the same thing, but not sure what to put on the Dependencies tab of the task properties. I have two jobs on a workflow and when the first job fails, I want it to restart five times and then if it finishes successfully, to go to the next job. If the first job fails five times, the second job shouldn't run.


  • 12.  How to execute a job more than the once post-conditions else allows

    Posted Oct 19, 2016 09:33 AM
    JGi604607 - Hi Judith, you don't need anything on the Dependencies tab - for Jim's solution to work you need to do what he suggests on the Postconditions tab of the first job in the workflow ...
    Open Postconditions tab, drag "STATUS" into the window from the "Conditions" subtab, in the Parameters select "Any_OK" from the dropdown menu, click OK. Then drag "USER DEFINED" across, enter &$RESTART_COUNT into "Value 1", "Operator is" < (less than), "Value 2" is No. of restarts required i.e 5, click OK. Then from the "Actions" subtab drag across "RESTART_TASK" - use this to determine the number of minutes you required between rerun attempts.
    Hope this helps. Ian.



  • 13.  How to execute a job more than the once post-conditions else allows

    Posted Oct 19, 2016 09:38 AM
    I assume you use line dependency between the jobs - on the dependencies tab of the 2nd job - you should have "All states must match" selected, the "job name" of the predecessor job, status should be "ANY_OK" - in the "ELSE" field select "Block" - this will block the 2nd job if the condition of the 1st in anything else bar "ANY_OK" - so the 2nd job will only ever execute on successful completion of job 1.


  • 14.  How to execute a job more than the once post-conditions else allows

    Posted Oct 19, 2016 10:19 AM
    Thanks IanFindon611036  for the quick response. I set up the job but now it won't stop running. I thought after running and failing 5 times, the job would abort.e38pvj8kued8.pnghttps://us.v-cdn.net/5019921/uploads/editor/4u/e38pvj8kued8.png" width="775">


  • 15.  How to execute a job more than the once post-conditions else allows

    Posted Oct 19, 2016 11:24 AM
    JGi604607 - the "STATUS" should be "ANY_OK" not "ENDED_NOT_OK" - then when any exception\failure condition is reported the job will then follow the User Defined\Restart Task condition and stop after 5 restarts.


  • 16.  How to execute a job more than the once post-conditions else allows

    Posted Oct 19, 2016 11:46 AM
    I had tried putting ANY_OK but the job didn't restart after it failed. Not sure what I am doing wrong.


  • 17.  How to execute a job more than the once post-conditions else allows

    Posted Oct 20, 2016 05:51 AM
    JGi604607 Apologies it is "ENDED_NO_OK" - not "ANY_OK".

    I'm struggling to get images saved in the discussion - so will reply in an email ..

    I set up a test this morning and using the postconditions in your example - my job executed and failed - then attempted a restart 5 times (so 6 executions) - before showing as failed in the workflow.




  • 18.  How to execute a job more than the once post-conditions else allows

    Posted Oct 20, 2016 06:44 AM
      |   view attached
    JGi604607 - Had issues with sending mail - have attached doc with screenshots

    Attachment(s)

    doc
    Reply to Judith.doc   245 KB 1 version


  • 19.  How to execute a job more than the once post-conditions else allows

    Posted Oct 20, 2016 09:51 AM
    Ian, what did you put on the task properties (dependencies tab) of the first & second job?
    This is what I have on the postcondition tab of the job report.
    2016-10-20 09:48:23 - IF task ended with status ENDED_NOT_OK
    2016-10-20 09:48:23 -    True: Task ended with status '1800' and return code '9009'.
    2016-10-20 09:48:23 - IF  0000000000000011 < 5
    2016-10-20 09:48:23 -    True
    2016-10-20 09:48:23 - FINALLY restart task in 1 minutes




  • 20.  How to execute a job more than the once post-conditions else allows

    Posted Oct 20, 2016 10:28 AM
      |   view attached
    Hi Judith, no task properties on the first job, and only added the postconditions on the 2nd job in the workflow.
    My postcondition report for the original failure and 4 restarts ...

    2016-10-20 09:45:51 - IF task ended with status ENDED_NOT_OK
    2016-10-20 09:45:51 -    True: Task ended with status '1800' and return code '1'.
    2016-10-20 09:45:51 - IF 0000000000000000 < 5   (this incrementing by 1 each time job restarted)
    2016-10-20 09:45:51 -    True
    2016-10-20 09:45:51 - FINALLY restart task in 1 minutes

    On the 5th restart the report shows 
    2016-10-20 09:52:28 - IF task ended with status ENDED_NOT_OK
    2016-10-20 09:52:28 -    True: Task ended with status '1800' and return code '1'.
    2016-10-20 09:52:28 - IF 0000000000000005 < 5
    2016-10-20 09:52:28 -    False

    See attached doc for task properties / workflow and job attributes configs


  • 21.  How to execute a job more than the once post-conditions else allows

    Posted Oct 20, 2016 10:55 AM
    Thanks for the screenshots Ian. Everything looked the same except for the workflow attributes. I had "after an error-free restart" and you have "after error-free execution." I changed it to "after error-free execution" but the job is still running after 6+ runs.
    Just to clarify, I have two jobs on a workflow. The first job is the job that needs to restart 5 times if it fails. Do I put the postcondition on the first or second job? I tried both but when I put it on the first job, the job doesn't stop restarting. When I put the conditions on the postcondition tab of the second job, the first job only runs once and doesn't restart after it fails.


  • 22.  How to execute a job more than the once post-conditions else allows

    Posted Oct 20, 2016 11:01 AM
    JGi604607 - You need to put the postconditions on the job you want restart - in this case the 1st job in the workflow. I'll set up a workflow with 2 jobs to simulate what you are trying to do.


  • 23.  How to execute a job more than the once post-conditions else allows

    Posted Oct 20, 2016 11:33 AM
      |   view attached
    JGi604607 - my simulation worked - stopped after the 5th restart attempt 

    Attachment(s)



  • 24.  How to execute a job more than the once post-conditions else allows

    Posted Oct 20, 2016 11:43 AM
    That's interesting that yours worked. I added a dummy job before the first job, then put the postcondition on the second job, and it stopped after the 5th restart! I'll rebuild the workflow again and see if it works. Thank you so much for your help Ian!


  • 25.  How to execute a job more than the once post-conditions else allows

    Posted Oct 20, 2016 12:17 PM
    Not sure what I did differently this time, but I rebuilt the workflow with just two jobs and it works!!! Thanks Ian!!!!  :)


  • 26.  How to execute a job more than the once post-conditions else allows

    Posted Oct 24, 2016 04:54 AM
    I love seeing jobs or objects with an ENDED_NOT_OK status in the activity window.... it makes you feeling that everything goes well in your production environment ....

    Why don't using an Event as indicated by Chris and Jim ? You can do all testing and run multiple times the checks on the file and when conditions are ok , process the file or raise an alarm if not present after some time.

    There is an UNIXFS module provided by Automic that is available for file checks in unix jobs or through a PREP_PROCESS command i.e. with many options if you don't use an Event File but an Event Time.

    Using pre-condition or post-condition is masking actions to the operation people when an Event is visible, indicates the processing of a condition and can be monitored, audited and generates a report !

    This is just my feedback about the approach to such problem : keep it simple and uses the basic functions of the product instead of the more sophisticated ones for a simple action. 

    At end you will do what you want but remember that maybe somebody else will have to look at this in 4 years from now and try to understand what where you doing at that time ....

    Alain