Periodically run a job -- manually

This job monitor checks and warns you if certain jobs aren't running.

Do you need to have a job run periodically but don't want to have to deal with manually starting it every time?...

I wrote a monitor to check, and warn me if certain jobs weren't running. I needed this "health monitor" to run every fifteen minutes but I did not want to have it sitting in QBATCH with a DLYJOB. Instead I submitted it as a scheduled job and then after it checks the jobs, it adds fifteen minutes to whatever time it is and submits itself as a scheduled job. With this code (and it could probably be cleaned up some), one could take any periodic job and have it run itself.


  
 *****************************************************                         
 * Submit the scheduled job                                                    
 *****************************************************                         
                                                                               
C     submitagain   begsr                                                      
                                                                               
 * First see if the health monitor is running                                  
C                   clear                   command                            
C                   eval      command = 'OVRPRTF FILE(QSYSPRT) HOLD(*YES) '    
C                             + 'OVRSCOPE(*JOB)'                               
C                   callp(e)  execcommand(command:length)                      
                                                                               
C                   clear                   command                            
C                   eval      command = 'WRKJOBSCDE JOB(XCHCOM'                
C                                    + %trim(invendid) + ') OUTPUT(*PRINT)'    
C                   callp(e)  execcommand(command:length)                      
                                                                               
C                   clear                   command                            
C                   eval      command = 'CPYF FROMFILE(JHAXCI/XCSPLF) '        
C                                     + 'TOFILE(QTEMP/XCSPLF) '                
C                                     + 'MBROPT(*REPLACE) '                    
C                                     + 'CRTFILE(*YES)'                        
C                   callp(e)  execcommand(command:length)                
                                                                         
C                   clear                   command                      
C                   eval      command = 'CPYSPLF FILE(QSYSPRT) '         
C                                     + 'TOFILE(QTEMP/XCSPLF) '          
C                                     + 'SPLNBR(*LAST) '                 
C                                     + 'MBROPT(*REPLACE)'               
C                   callp(e)  execcommand(command:length)                
                                                                         
C                   callp     dltovr('QSYSPRT')                          
                                                                         
C                   clear                   command                      
C                   eval      command = 'DLTSPLF FILE(QSYSPRT) '         
C                                     + 'SPLNBR(*LAST)'                  
C                   callp(e)  execcommand(command:length)                
                                                                         
C                   callp     ovrdbfqtemp('XCSPLF')                      
C                   open      xcsplf                                     
C                   do        5                                          
C                   read      rxcsplf                                99  
C                   enddo                                                
C                   close     xcsplf                                     
C                   callp     dltovr('XCSPLF')                           
                                                                          
 * If health monitor is running then end this madness                     
C                   if        %subst(splfdata:2:10) = 'XCHCOM' + invendid 
C                   goto      endpgm                                      
C                   endif                                                 
                                                                          
C                   time                    ztime                         
C                   adddur    15:*minutes   ztime                         
C                   extrct    ztime:*m      zmm                           
C                   extrct    ztime:*d      zdd                           
C                   extrct    ztime:*y      zyyyy                         
C                   move      zyyyy         zyy                           
C                   extrct    ztime:*h      zhh                           
C                   extrct    ztime:*mn     zmn                           
C                   extrct    ztime:*s      zss                           
                                                                          
C                   clear                   command                       
                                                                          
C                   eval      command = 'ADDJOBSCDE JOB(XCHCOM'           
C                             + %trim(invendid)                           
C                             +  ') CMD(CALL PGM(JHAXCI/XCHCOM) '         
C                             +  'PARM(''*Next'' ''' + %trim(invendid)    
C                             +  ''')) FRQ(*ONCE) '                       
C                             +  'SCDDATE(' + zmm + zdd + zyy + ') '      
C                             +  'SCDTIME(' + zhh + zmn + zss + ') '
C                             +  'MSGQ(*NONE) '                     
C                             +  'TEXT(''JHAXCI Health Monitor'')'  
                                                                    
C                   callp(e)  execcommand(command:length)           
                                                                    
C                   endsr      
  
  

This was last published in May 2003

Start the conversation

Send me notifications when other members comment.

By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Please create a username to comment.

-ADS BY GOOGLE

SearchEnterpriseLinux

SearchDataCenter

Close