How can we help you?

We have hundreds of highly-qualified, experienced experts working in 70+ technologies.

IBM i e-Book

A Developer’s Guide to Mastering IBM i Concepts

Jobs & Logs

Job Schedule

IBMi job scheduling allows organizations to automate repetitive tasks and operator functions through the unattended operation of the Jobs. Job scheduling eases the task of an operator by submitting the jobs on a pre-defined schedule. It eliminates the need to write control language programs to perform routine tasks.On IBMi system, job scheduling can be done using IBM-provided commands and through IBMi advanced job scheduler as well which comes packaged with IBMi operating system (License 5722-JS1).

Scheduling a job using schedule entry related commands

A job can be scheduled and viewed/modified on job schedule using the below commands:

(a) ADDJOBSCDE (Add Job Schedule Entry)
This command is used to schedule a batch job by adding an entry to the job schedule.
Below are the important parameters that need to be considered while adding a job to the schedule:

  1. JOB: It is the name of the job which appears on the schedule list once added and it will also be the name of the job which will be submitted.
  2. CMD: It is the command that will run when the job is submitted on the specified schedule, generally it’s the call command for a program.
  3. FRQ: It is the frequency of the job submission. Below are the possible values for this parameter and when to use these values:
    • *ONCE: If a job needs to be submitted only one time.
    • *WEEKLY: If a job needs to be submitted daily OR on a few selected days of the week.
    • *MONTHLY: If a job needs to be submitted on a few selected dates of the month (like the first date of every month).
    • *YEARLY: If a job needs to be submitted only once a year.
  4. SCDDAY/SCDDATE: These are the parameters for scheduled days & scheduled dates for the job.For jobs that are supposed to be executed daily or on specific days of every week, the SCDDATE parameter is supplied as *NONE, and the SCDDAY parameter is supplied with the name of the days.For jobs that are supposed to be submitted once, monthly, OR yearly; the SCDDAY parameter is supplied as *NONE, and the SCDDATE parameter is updated as a specific date, *MONTHSTR or *MONTHEND.
  5. SCDTIME: It is the time of the day at which the job is supposed to be executed.
  6. JOBD:The job description parameter specifies the JOBD using which the job will be executed. The JOBD contains the list of libraries which will be used by the job to perform the required actions given in program.
  7. JOBQ: This is the JOBQ in which the job will be submitted, generally for batch jobs it is kept as QBATCH.
  8. USER: It specifies the name of the user using whose authorities the scheduled job will be executed. Possible values are:
    • *CURRENT – The job is submitted under the user profile of the user who is adding the job schedule entry.
    • *JOBD – The job will be submitted using the user profile of the JOBD.
    • A specific name of the user profile can also be provided.

Below are some examples of adding a new job schedule entry for different scenarios:

  • Scheduling a one-time job

    The above command translates to “The job TODAYRPT will be submitted on 25th March 2024 at 10:30 PM on JOBQ ‘QBATCH’ using profile AZARU to call the program GENDAILYRP from library PGMLIB”.

  • Scheduling a job to execute a program on daily basis:

    The above command translates to “The job DAILYRPT will be submitted on ALL days of every week (i.e. daily) at 10:30 AM in the morning on JOBQ ‘QBATCH’ using profile AZARU to call the program GENDAILYRP from library PGMLIB”.

(b) WRKJOBSCDE (Work with Job Schedule Entries)
This command allows the user to work with the existing scheduled entries of the jobs to change, remove, display, hold, release, check the last submission details of the job OR submit the job immediately if needed.Below are some sample executions of this command:

  • Change the scheduled job.

    Provide the name of the job (if want to work only with specific job) and press enter.

    Option 2 can be taken to change the job (i.e. change any parameter which was used to add the scheduled entry of the job). Let’s assume that we want to change the scheduled time of “DAILYRPT” job from 10:30 am to 11:00 am. On taking option 2 below screen appears:

    We can change the time as below and press enter to update the scheduled entry of the job.



    *It can be observed that when option 2 is taken on the scheduled entry, the command CHGJOBSCDE is executed. This command can directly be used to change the parameter of scheduled entry from command line.

  • Hold/Release the scheduled job.In case it is needed to hold the job from getting submitted for the next execution (or release the scheduled entry of the job if it was held before), option 3 can be taken (option 6 can be taken to release the scheduled entry).

    As we can see above the job is currently in SCD (Scheduled) status and it will be submitted at 11:00 AM, to stop it from getting submitted at 11:00 AM, option 3 can be taken as below:


    Job status gets changed to “HLD” (Held) as shown above.

    To release this job (or bringing it back to SCD status) option 6 can be taken as below:


    First the job status is changed from “HLD” to “RLS” (released), on pressing F5 status gets updated correctly to SCD

    *Scheduled entries can be held/released by commands HLDJOBSCDE/RLSJOBSCDE as well

  • Work with last submission.To work with the most recent submission of the job by scheduled entry, option 8 can be taken.

  • Submit immediately.If we want to submit the scheduled entry immediately, we can take option 10.

    *We can observe, by submitting the job immediately didn’t change any this on “next submit date” column. So, submitting the job using option 10 does not impact the scheduled entry of the job. It can also be achieved using SBMJOB command.

  • Remove job schedule job.If we want to remove the scheduled entry, we can take option 4 to do the same:

    System asks for the confirmation, press enter again.

    Scheduled entry gets removed.

    *A scheduled entry can also be removed using command RMVJOBSCDE.

(c) How to know the scheduled job entry number of all scheduled entries
There are commands like CHGJOBSCDE, HLDJOBSCDE, RLSJOBSCDE, RMVJOBSCDE which require you to supply job entry number along with the scheduled job name (in case there are multiple scheduled entries available with the same name).The job entry number is automatically assigned by system when we add a new scheduled entry in system using ADDJOBSCDE (or by pressing F6 from WRKJOBSCDE command).

To see all the scheduled job details in system (along with scheduled job entry number), we can either print all scheduled entries details using WRKJOBSCDE command OR alternatively we can also use the view “SCHEDULED_JOB_INFO” (Short name SCHED_JOB) which is available in QSYS2 library.

It can be accessed using SQL session and data filtering criteria can also be applied.



Scheduling a job using submit job command.

In case it is required to run a job not immediately but at a particular date/day and time (once only), it can also be achieved using SMBJOB command.

We can supply the parameters “SCDDATE” and “SCDTIME” for this purpose.

SCDDATE can either be a specific date OR a name of day (*MON/*TUE etc.) or month start/month end (*MONTHSTR/*MONTHEND) as well. If needed to submit the job on the same day but at some other time, we can consider not to provide SCDDATE parameter (keep it as *CURRENT) and provide only SCDTIME parameter.

SCDTIME parameter is used to provide the time at which the job will be submitted.

Below is a sample to schedule a job using SMBJOB command:

  • Sample one time execution scheduling using SBMJOB command.

    The above command will schedule the job to run at 11:00 AM on 26th Apr 2024.

    The scheduled entries will reside in JOBQ with status SCD till the time to submit is reached. We can see these entries using WRKJOBQ command.

    On entering command WRKJOBQ JOBQ(QBATCH), below entry appears:

    *If needed we can change, hold, end, or release the job from the JOBQ. The corresponding commands are CHGJOB, HLDJOB, ENDJOB, RLSJOB to do the same activities.

Scheduling a job using the Advance job scheduler

IBM has also provided an advanced job scheduler package which comes with more flexibilities and options for user which scheduling the jobs (like having holiday calendar, group jobs to run one after other, multiple submissions of a job at different times on same day etc.).

The scheduler can be accessed using the menu command “GO JS” and different options can be used to add/update/remove a job in advance job scheduler. Moreover, different calendars can also be maintained.

IBM has provided a red book for its manual which can be accessed below, you can go through this red book to understand different options of advance job scheduler.

AS400 Job scheduler

How can we help you?

We have hundreds of highly-qualified, experienced experts working in 70+ technologies.

share_iconShare
X

Awards and Certifications

company-logo
company-logo
company-logo
company-logo
company-logo
company-logo
company-logo
company-logo
company-logo
company-logo