Normally we can trigger an On Do Action based on string found in the Job Output.
But we would like to do the same for a Job log, that feature doesn’t exist, but there is a way to make it working.
Let’s see how to proceed.

Introduction

For example: as a use case:
See the blog How to automate a kill of one or several executing jobs in AJF at specific Date/Time at once, when the a running job is killed in purpose with the ctmkilljob utility, the job ends with a NOTOK State (red).
The issue of that, if we manage a On-Do Action on NOTOK situations, those Actions will be triggered.
We can avoid triggering those On-Do Actions for this specific context (job killed) by following the procedure below.
In this example, we will re-use the same case which is to automate a Kill of a job from another job:

Preparation

Define 2 jobs

  • Ctmtst-Job-Killer: Job which runs ctmkilljob utility to end another job

  • With PARM1= Ctmtst-To-Kill

  • Ctmtst-To-Kill: Job with short name to be killed but should end OK
    => Its Output should contain the text in the script
  • After running the jobs, t1ctmtst-To-Kill ends NOTOK as expected, and might trigger an unwanted ON DO ACTION if a NO OK is monitored

    See below Job log

    22:36:08 1/23/2022     STARTED AT 20220123223607 ON ctmsrv.domain.com      5101
    22:36:08 1/23/2022     JOB STATE CHANGED TO Executing  5120
    22:36:26 1/23/2022     JOB KILLED BY USER [email protected]   5409
    22:36:27 1/23/2022     ENDED AT 20220123223627. OSCOMPSTAT 1. RUNCNT 1   5100
    22:36:27 1/23/2022     Message from Agent: /opt/cmagt/ctm/sysout/Ctmtst_To_Kill.LOG_00iyte_00001   5169
    22:36:27 1/23/2022     ENDED NOTOK. NUMBER OF FAILURES SET TO 1     5134
    

    As we wanted to kill the job in purpose, then we would like to trigger the Set To OK in On Do Action

  • Solution

    1. Capture the Job log with the ctmlog command, the result will be append to the Job ouput
      • ctmlog listord %%ORDERID %%DATE 0000 %%DATE 2359
        

        The job output will contain its regular output and at the end also the job log as the result of ctmlog command

        + echo Start Job
        Start Job
        + sleep 300
        Date: 23-01-2022.   Page: 1
        Date: 23-01-2022.   Page: 1
        
            CTMLOG REPORT from 20220123 000000 to 20220123 235959
        
        Orderno : 0iyte (*884930)
        
        +-------------------------------------------------------------------------------------------------
        |Date|Time|Jobname              |Order|SS|MID |Message
        +-------------------------------------------------------------------------------------------------
        |0123|2236|Ctmtst-To-Kill_1     |0iyte|CS|5065|ORDERED JOB:31790; DAILY FORCED, ODATE 20220123
        |0123|2236|Ctmtst-To-Kill_1     |0iyte|SL|5105|SUBMITTED TO [email protected]
        |0123|2236|Ctmtst-To-Kill_1     |0iyte|TR|5101|STARTED AT 20220123223607 ON [email protected]
        |0123|2236|Ctmtst-To-Kill_1     |0iyte|TR|5120|JOB STATE CHANGED TO Executing 
        |0123|2236|Ctmtst-To-Kill_1     |0iyte|UT|5409|JOB KILLED BY USER [email protected]
        
    2. Last step, is to define the On Do Action Set to OK for this specific context (Job KILLED)
      • On Do Action definition
      • The Job will end OK and the log will contain
      • final state

      Enjoy 🙂


    Thumbnail [60x60]
    by
    Mamy Rasoanaivo