In this module, we will delve into advanced job scheduling techniques in Control Language (CL). Job scheduling is a critical aspect of system management, allowing you to automate tasks, manage workloads, and ensure that jobs are executed at the right time and in the correct sequence.

Key Concepts

  1. Job Scheduling Basics: Review of basic job scheduling concepts.
  2. Advanced Scheduling Commands: Introduction to advanced commands for job scheduling.
  3. Job Dependencies: Managing job dependencies and sequences.
  4. Job Prioritization: Setting job priorities and managing job queues.
  5. Scheduling Recurring Jobs: Automating recurring tasks.
  6. Monitoring and Managing Scheduled Jobs: Tools and techniques for monitoring and managing scheduled jobs.

  1. Job Scheduling Basics

Before diving into advanced techniques, let's briefly review the basics of job scheduling in CL.

Basic Job Scheduling Commands

  • SBMJOB (Submit Job): Submits a job to a job queue.
  • WRKJOB (Work with Job): Displays information about jobs.
  • WRKJOBQ (Work with Job Queue): Displays and manages job queues.

Example

SBMJOB CMD(CALL PGM(MYPGM)) JOB(MYJOB) JOBQ(QBATCH)

This command submits the job MYJOB to the job queue QBATCH to run the program MYPGM.

  1. Advanced Scheduling Commands

2.1. ADDJOBSCDE (Add Job Schedule Entry)

The ADDJOBSCDE command is used to schedule jobs to run at specific times and dates.

ADDJOBSCDE JOB(MYJOB) CMD(CALL PGM(MYPGM)) SCDDATE('2023-12-25') SCDTIME('12:00:00') FRQ(*WEEKLY) SCDDAY(*MON)

This command schedules MYJOB to run the program MYPGM every Monday at 12:00 PM starting from December 25, 2023.

2.2. CHGJOBSCDE (Change Job Schedule Entry)

The CHGJOBSCDE command modifies an existing job schedule entry.

CHGJOBSCDE JOB(MYJOB) SCDTIME('14:00:00')

This command changes the scheduled time of MYJOB to 2:00 PM.

2.3. RMVJOBSCDE (Remove Job Schedule Entry)

The RMVJOBSCDE command removes a job schedule entry.

RMVJOBSCDE JOB(MYJOB)

This command removes the scheduled job MYJOB.

  1. Job Dependencies

Managing job dependencies ensures that jobs are executed in the correct order.

Example

SBMJOB CMD(CALL PGM(MYPGM1)) JOB(MYJOB1) JOBQ(QBATCH)
SBMJOB CMD(CALL PGM(MYPGM2)) JOB(MYJOB2) JOBQ(QBATCH) JOBD(MYJOBD)

In this example, MYJOB2 can be set to run only after MYJOB1 completes by using job descriptions and dependencies.

  1. Job Prioritization

Setting job priorities helps manage the execution order of jobs in a job queue.

Example

SBMJOB CMD(CALL PGM(MYPGM)) JOB(MYJOB) JOBQ(QBATCH) JOBPTY(5)

This command submits MYJOB with a priority of 5. Lower numbers indicate higher priority.

  1. Scheduling Recurring Jobs

Automating recurring tasks is essential for efficient system management.

Example

ADDJOBSCDE JOB(MYJOB) CMD(CALL PGM(MYPGM)) SCDDATE('2023-12-25') SCDTIME('12:00:00') FRQ(*DAILY)

This command schedules MYJOB to run MYPGM daily at 12:00 PM starting from December 25, 2023.

  1. Monitoring and Managing Scheduled Jobs

6.1. WRKJOBSCDE (Work with Job Schedule Entries)

The WRKJOBSCDE command displays and manages job schedule entries.

WRKJOBSCDE

This command opens a panel where you can view, change, and remove job schedule entries.

6.2. DSPJOBLOG (Display Job Log)

The DSPJOBLOG command displays the job log, which is useful for monitoring job execution and troubleshooting.

DSPJOBLOG JOB(MYJOB)

This command displays the job log for MYJOB.

Practical Exercise

Exercise 1: Schedule a Weekly Backup Job

  1. Objective: Schedule a job to run a backup program every Sunday at 2:00 AM.
  2. Steps:
    • Create a CL program named BACKUPPGM.
    • Use the ADDJOBSCDE command to schedule the job.

Solution

// Create the backup program (BACKUPPGM)
PGM
    /* Backup commands go here */
ENDPGM

// Schedule the job
ADDJOBSCDE JOB(BACKUPJOB) CMD(CALL PGM(BACKUPPGM)) SCDDATE('2023-12-25') SCDTIME('02:00:00') FRQ(*WEEKLY) SCDDAY(*SUN)

Common Mistakes and Tips

  • Incorrect Date/Time Format: Ensure the date and time are in the correct format (YYYY-MM-DD and HH:MM:SS).
  • Job Queue Availability: Verify that the job queue specified is available and not held.
  • Job Dependencies: Clearly define job dependencies to avoid execution issues.

Conclusion

In this module, we covered advanced job scheduling techniques in CL, including the use of advanced scheduling commands, managing job dependencies, setting job priorities, scheduling recurring jobs, and monitoring scheduled jobs. These skills are essential for efficient system management and automation. In the next module, we will explore advanced file operations in CL.

© Copyright 2024. All rights reserved