Get Job Status by Subsystem, Job Name or User Profile in AS400 (IBMi Power System)

This information is very useful if you want to keep an eye on long running server jobs for status updates, may be check for jobs on message wait.
Here is how you can do it with a very simple SQL

OS version 7.2 or higher

SELECT JOB_NAME, JOB_TYPE, JOB_STATUS,SUBSYSTEM, 
      AUTHORIZATION_NAME JOB_USER,            
      ELAPSED_CPU_PERCENTAGE AS PERCENT                               
      FROM TABLE(QSYS2.ACTIVE_JOB_INFO(JOB_NAME_FILTER => '*ALL')) A  
      where SUBSYSTEM = 'QSERVER'                                     
      ORDER BY SUBSYSTEM, ELAPSED_CPU_PERCENTAGE DESC       

OS version 7.1 or lower

SELECT JOB_NAME, JOB_TYPE, JOB_STATUS,SUBSYSTEM,                  
      AUTHORIZATION_NAME JOB_USER,                                
      ELAPSED_CPU_PERCENTAGE AS PERCENT                           
      FROM TABLE(QSYS2.ACTIVE_JOB_INFO('NO', '', '*ALL', '')) A   
      where SUBSYSTEM = 'QSERVER'                                 
      ORDER BY SUBSYSTEM, ELAPSED_CPU_PERCENTAGE DESC             

Let's say you want to check for a specific job status

SELECT JOB_NAME, JOB_TYPE, JOB_STATUS,SUBSYSTEM, 
      AUTHORIZATION_NAME JOB_USER,                      
      ELAPSED_CPU_PERCENTAGE AS PERCENT                               
      FROM TABLE(QSYS2.ACTIVE_JOB_INFO(JOB_NAME_FILTER => '*ALL')) A  
      where SUBSYSTEM = 'QSERVER'                                     
            and JOB_STATUS in ('MSGW','TIMW')                         
      ORDER BY SUBSYSTEM, ELAPSED_CPU_PERCENTAGE DESC 

Let's say you want to check for a specific job status by a certain user

SELECT JOB_NAME, JOB_TYPE, JOB_STATUS,SUBSYSTEM, 
      AUTHORIZATION_NAME JOB_USER,                          
      ELAPSED_CPU_PERCENTAGE AS PERCENT                                   
      FROM TABLE(QSYS2.ACTIVE_JOB_INFO(JOB_NAME_FILTER => '*ALL')) A      
      where (SUBSYSTEM = 'QSERVER' and                                    
                   AUTHORIZATION_NAME like '%QUSER%' )                    
            and JOB_STATUS in ('MSGW','TIMW')                             
      ORDER BY SUBSYSTEM, ELAPSED_CPU_PERCENTAGE DESC                     

Here is the Result SET

JOB_NAME                      JOB_TYPE  JOB_STATUS  SUBSYSTEM         PERCENT        
103929/QUSER/QPWFSERVSO         PJ         TIMW     QSERVER                .0        
120560/QUSER/QPWFSERVSO         PJ         TIMW     QSERVER                .0        
123371/QUSER/QPWFSERVSO         PJ         TIMW     QSERVER                .0        
124578/QUSER/QZLSFILET          PJ         TIMW     QSERVER                .0  

No comments:

Post a Comment

NO JUNK, Please try to keep this clean and related to the topic at hand.
Comments are for users to ask questions, collaborate or improve on existing.