Search code examples
ibm-midrange

Is there any way to identify that the job was ended manually with option '4'


Some of the jobs got ended with the below message. "Profilexxxx has issued a controlled shutdown request for work". How to check if these jobs were ended manually by taking option '4'. The jobs ends and restarts everyday. When I check the previous day joblogs I could see the message CPC1125, and when the job ended abnormally it was cpc1126 and CPC1235.


Solution

  • There are several ways that a job can end. The normal ways are:

    1. Normal end - The programs end normally without any messages.
    2. Controlled end of job - The job is ended by taking a 4 on the job in WRKACTJOB or by calling ENDJOB.
    3. Immediate end of job - The job is ended by taking 4 on the job in WRKACTJOB or by calling ENDJOB with OPTION(*IMMED).
    4. Controlled end of the subsystem - The subsystem the job is running in is ended by calling ENDSBS.
    5. Immediate end of the subsystem - The subsystem the job is running in is ended by calling ENDSBS with OPTION(*IMMED).
    6. Program failure. User takes a C or D on the message.

    There are others, but they are less likely. In fact, the ENDSBS OPTION(*IMMED) is not terribly likely either, but easy to test.

    One thing to notice right away is that jobs can be configured to only spool a job log when the job ends abnormally. In this case you should only get a job log for reason 6 above. Otherwise, the following will be found in job logs of the job that was ending:

    1. Normal end - Only CPF1164 with end code 0. No escape messages are present in the job log.

    CPF1164 Completion 00 03/26/19 09:06:14.261295 QWTMCEOJ QSYS 0162 *EXT *N

    Message . . . . : Job 274217/MMURPHY/MMURPHY ended on 03/26/19 at 09:06:14; .005 seconds used; end code 0 .

    1. Controlled end of job - Again no escape messages, but CPC1126 will be present. End code is 10 on CPF1164. This shows the user profile that ended the job.

    CPC1126 Completion 50 03/26/19 08:42:37.604265 QWTCCCNJ QSYS 0C74 *EXT *N

    Message . . . . : Job 274196/MMURPHY/MMURPHY was ended by user MMURPHY.

    Cause . . . . . : User MMURPHY issued a controlled end job request for job 274196/MMURPHY/MMURPHY.

    CPF1164 Completion 00 03/26/19 08:42:37.607135 QWTMCEOJ QSYS 0162 *EXT *N

    Message . . . . : Job 274196/MMURPHY/MMURPHY ended on 03/26/19 at 08:42:37; 6.291 seconds used; end code 10 .

    1. Immediate end of job - Again no escape messages, but CPC1125 will be present. End code is 50 on CPF1164. This shows the user profile that ended the job.

    CPC1125 Completion 50 03/26/19 08:44:46.773821 QWTCCCNJ QSYS 0C74 *EXT *N

    Message . . . . : Job 274200/MMURPHY/MMURPHY was ended by user MMURPHY.

    Cause . . . . . : User MMURPHY issued an immediate end job request for job 274200/MMURPHY/MMURPHY.

    CPF1164 Completion 00 03/26/19 08:44:46.774951 QWTMCEOJ QSYS 0162 *EXT *N

    Message . . . . : Job 274200/MMURPHY/MMURPHY ended on 03/26/19 at 08:44:46; 5.661 seconds used; end code 50 .

    1. Controlled end of subsystem - No escape message, CPC1206 will be present. No indication of who issued ENDSBS. End code 10 in CPF1164.

    CPC1206 Completion 50 03/26/19 08:52:59.936053 QWTMMTRS QSYS 0370 *EXT *N

    From user . . . . . . . . . : QSYS

    Message . . . . : Subsystem is ending controlled.

    CPF1164 Completion 00 03/26/19 08:52:59.939458 QWTMCEOJ QSYS 0162 *EXT *N

    Message . . . . : Job 274207/MMURPHY/MMURPHY ended on 03/26/19 at 08:52:59; 16.004 seconds used; end code 10 .

    1. Immediate end of subsystem - No escape message, CPC1207 will be present. No indication of who issued ENDSBS. End code 10 in CPF1164.

    CPC1207 Completion 50 03/26/19 09:05:00.642584 QWTMMTRS QSYS 0370 *EXT *N

    From user . . . . . . . . . : QSYS

    Message . . . . : Subsystem ending immediately.

    CPF1164 Completion 00 03/26/19 09:05:00.643785 QWTMCEOJ QSYS 0162 *EXT *N

    Message . . . . : Job 274213/MMURPHY/MMURPHY ended on 03/26/19 at 09:05:00; 14.583 seconds used; end code 50 .

    1. Program failure - There will be escape messages prior to the CPF1164, potentially a CEE9901 if the program is an ILE RPG program, maybe others depending on the program type that ended abnormally. You will likely see an inquiry message with a reply of C, D, or F. These all cancel the program, and if it is the top program in the stack, it will cancel the job. Be careful though, CL programs allow a reply of R or I to the inquiry message which will not cancel the job, but retry or ignore the failing program. So not all escape message will cause the job to fail, only unmonitored ones. Surprisingly the CPF1164 will have an end code of 0 as the job really does not fail, but it is ended normally after handling of the escape messages sent by the top program in the stack.

    For the job that is calling ENDJOB or ENDSBS, these will be logged as well, but once again, it could be that the job is configured to suppress the job log in the event of a successful completion, so you might not see it. The ENDJOB message is CPC1231 and shows the job that was ended. This happens when the user takes a 4 against the job.

    Message ID . . . . . . :   CPC1231       Severity . . . . . . . :   00      
    Message type . . . . . :   Completion                                       
    Date sent  . . . . . . :   03/26/19      Time sent  . . . . . . :   08:44:46
    
    Message . . . . :   ENDJOB started for job 274200/MMURPHY/MMURPHY.          
    Cause . . . . . :   The End Job (ENDJOB) command is running for job         
      274200/MMURPHY/MMURPHY.                                                   
    

    If the user ends the job by typing ENDJOB or ENDSBS on the command line you will see a request message like this:

    From . . . . . . . . . :   MMURPHY       Severity . . . . . . . :   00      
    Message type . . . . . :   Request                                          
    Date sent  . . . . . . :   03/26/19      Time sent  . . . . . . :   08:52:57
    
    Message . . . . :   ENDSBS SBS(MMURPHY)     
    

    Unfortunately in the case of the subsystem, there is no indication of which jobs were ended.