7 Replies Latest reply on Oct 22, 2018 4:24 AM by MunKeong Lee

    How to set rerun upon job failure on cyclic jobs

    Andy Teo
      Share:|

      Hi,

       

      I have request to rerun a cyclic job (interval 60 mins), upon job failure, and the rerun is every 10mins, for total of 3 times.

      The cyclic job itself will auto rerun regardless of job success or failure, base on its interval of 60mins.

      I tested setting on-do action to rerun (upon job failure) on cyclic job, but the result doesn't work out.

      Is there any other ways/workarounds for this requirement?

       

      regards

      andy

        • 1. Re: How to set rerun upon job failure on cyclic jobs
          MunKeong Lee

          Hi Andy

          I don't think you can achieve what you want using a single job. I suggest you create another cyclic job which executes the same command/script. In this new cyclic job, define the cyclic interval as shown below. If you use the normal Rerun Interval, this job will execute immediately once it has been ordered which I don't think is what you want. Add an On-Do action to Stop Cyclic to prevent further execution if job ended OK. In your original job, use an On-Do action do order the new job when job ended Not OK.

          Regards,

          MK

           

          1 of 1 people found this helpful
          • 2. Re: How to set rerun upon job failure on cyclic jobs
            Andy Teo

            Thanks MK!

            everything worked fine except for the ordered job runs immediately instead of waiting for 10mins for the 1st run. Trying to find ways to overcome this like setting pre-command sleep for 10mins but the execution time for the job will include the sleep time too, which is not correct.

            Is there a way to overcome this? (1st run for adhoc ordered job to wait for 10mins before it runs)

            • 3. Re: How to set rerun upon job failure on cyclic jobs
              MunKeong Lee

              Hi Andy

              Looks like I have made the wrong assumption on the behaviour of using interval sequence. I thought it will introduce a wait of 10 mins before executing.

              I have a solution but it requires you to add a new job. Create a new job which sleep for 10 minutes and link this sleep job (sleep)  to your new cyclic job (C2). You can change C2 to use a normal rerun interval of 10 minutes with 3 maximum reruns. Make sure that schedule for sleep and C2 are set to None. The On-Do actions for C2 should be as shown. It must also remove the condition when the rerun count reaches 3. This is to prevent another new instance of C2 from running immediately without waiting for sleep.

               

              The On-Do actions of the original cyclic job should also be changed to order 2 jobs on job ended Not OK:  sleep & C2.

               

              Let me know if this works for you. I did not test this fully. The flow will look messy though if the 1st cyclic job order sleep & C2 multiple times because the condition from sleep to C2 is the same. Hopefully, someone else can come up with a more elegant solution.

              Regards,

              MK

              2 of 2 people found this helpful
              • 4. Re: How to set rerun upon job failure on cyclic jobs
                Andy Teo

                Thanks MK.

                I tested out and your method is working. The sleep job needs to be cyclic and set to rerun 3 times too.

                • 5. Re: How to set rerun upon job failure on cyclic jobs
                  MunKeong Lee

                  Hi Andy

                  You may be able to make it work by making the sleep job cyclic but it's more complicated. I want the sleep job to execute only once to introduce the 1st 10 minutes delay. Subsequent rerun of C2 does not need to depend on the sleep job because C2 is configured to have cyclic interval of 10 minutes and the in-condition of C2 is already created once the sleep job completes. Therefore, C2 does not need to wait for the sleep job any more after the first execution if there's a need to rerun.

                  I found a mistake though. Job's number of reruns Equal to 3 does not work. I have to change to Job's number of executions Equal to 3.

                  • 6. Re: How to set rerun upon job failure on cyclic jobs
                    Andy Teo

                    got it. The non-cyclic sleep job is just to ensure the C2 will only run after 10mins later instead of running immediately upon ordered in. C2 (with cyclic interval = 10mins) will continue to rerun every 10mins when it failed. On the 3rd run, when it still fail, we need to remove the in-condition, so that next ordered C2 will not run immediately.

                    • 7. Re: How to set rerun upon job failure on cyclic jobs
                      MunKeong Lee

                      That's entirely correct!