IBM Support

How do you end a large amount of Jobs with similar names quickly

Question & Answer


Question

How do you end a large amount of Jobs with similar names quickly.

Cause

There might be a time where a run away job starts thousands of job in the system.  This document creates an automated way of ending them using SQL.

Answer

With the introduction of the IBM i SQL Service ACTIVE_JOB_INFO table function, you can create an SQL that selects and issues an ENDJOB for a list of active similar jobs on the system.  

Authorization: None required to see general information or information about your own jobs.

For DETAILED_INFO => ALL:
  • All users can see detailed column information for CLIENT_IP_ADDRESS, PAGE_FAULTS, JOB_ACTIVE_TIME, PRESTART_JOB_REUSE_COUNT, and PRESTART_JOB_MAX_USE_COUNT.
  • A user with QIBM_DB_SQLADM or QIBM_DB_SYSMON function usage authority can see detailed column information that relates to SQL activity starting with the SQL_STATEMENT_TEXT column through the PSEUDO_CLOSED_CURSOR_COUNT column.
  • For a user with *JOBCTL user special authority, all detailed column information is returned.
To get a listing of all active jobs with similar names follow the steps:
 
1) Open the ACS Run SQL Scripts tool 
2) Run the following SQL:
  WITH TEMPJOB (JOB_NAME) AS (
        SELECT JOB_NAME
            FROM TABLE (
                    QSYS2.ACTIVE_JOB_INFO()
                ) AS X
            WHERE JOB_NAME LIKE '%TESTV%' -- Specify the name of the job.
    )
    SELECT JOB_NAME,
           QSYS2.QCMDEXC('ENDJOB JOB(' || JOB_NAME || ') OPTION(*IMMED) LOGLMT(0)') AS "Success?"
        FROM TEMPJOB;    
		
image-20240626073556-1
NOTE 1: The SQL issues the command ENDJOB for each job that has 'TESTV' as part of the job name.   Change the SQL to match the name of the jobs in your system.
NOTE 2: The SQL has no confirmation screen and will end all jobs that match the selection criteria. 
NOTE 3: '1' on the Completion column indicates that the ENDJOB completed normally, a '-1' indicates the it failed. 
NOTE 4: The above SQL only works on Releases R730 and above.
NOTE 5:  No Joblogs are generated. 

[{"Type":"MASTER","Line of Business":{"code":"LOB68","label":"Power HW"},"Business Unit":{"code":"BU070","label":"IBM Infrastructure"},"Product":{"code":"SWG60","label":"IBM i"},"ARM Category":[{"code":"a8m0z0000000CHAAA2","label":"Operating System"}],"ARM Case Number":"","Platform":[{"code":"PF012","label":"IBM i"}],"Version":"7.3.0;7.4.0;7.5.0"}]

Document Information

Modified date:
26 June 2024

UID

ibm16244954