IBM Support

Scheduling Jobs to Run at a Specific Time

Troubleshooting


Problem

To schedule a batch job, use the Submit Job (SBMJOB) command, and specify values other than the defaults for the SCDDATE and SCDTIME parameters. Or, define a job schedule entry using the Add Job Schedule Entry (ADDJOBSCDE) command.

Resolving The Problem

To schedule a batch job, either use the Submit Job (SBMJOB) command and specify values other than the defaults for SCDDATE and SCDTIME parameters, or define a job schedule entry using the Add Job Schedule Entry (ADDJOBSCDE) command.

Scheduled Jobs

The Submit Job (SBMJOB) command is an easy way to schedule a job that needs to run only once. It also enables the use of many of the job attributes defined to your current job. However, because the SBMJOB command places the job on the job queue immediately, if the job queue is cleared before the schedule date and time, you lose your scheduled job.

When a job queue with a scheduled job is cleared, the scheduled job is handled similarly to any other job on the job queue. The job is removed from the job queue, and a message indicating that the job ended abnormally is issued to the message queue specified on the SBMJOB command. If the deleted job needs to remain scheduled, the program that submitted the job should monitor this message queue and submit the job again if it receives the message.

To print a list of jobs that were scheduled on the Submit Job (SBMJOB) command, on the operating system command line type the following:

WRKSBSJOB SBS(*JOBQ) OUTPUT(*PRINT)

Press the Enter key.

Job Schedule Entry

Use a job schedule entry to schedule jobs to recur or to run only once,. You may want to schedule a job to recur if it is a repetitious task, such as calculating payroll, filling out timecards, or sending out meeting notices. Since job schedule entries are entries in a permanent object, they do not stay on the job queue like the scheduled jobs and, therefore, they are not lost when the job queue is cleared.

To schedule a job by adding a job schedule entry, use the Add Job Schedule Entry (ADDJOBSCDE) command. This command adds an entry to the job schedule object.

Job Schedule Entry Commands

You can add, change, hold, release, and remove a job schedule entry using the following commands:
Command Description
ADDJOBSCDE Add a job schedule entry to the job schedule.
CHGJOBSCDE Change a job schedule entry. This command changes the entry in the job schedule, but it does not affect any jobs already submitted using this entry.
HLDJOBSCDE Hold a job schedule entry. If an entry is held, no job is submitted at the scheduled time due to the held status.
RLSJOBSCDE Release a job schedule entry. If the scheduled time has not yet been reached, the status is changed to scheduled (SCD). If the scheduled time has passed while the entry was held, no jobs are submitted, and a warning message is sent to indicate that a job or jobs were missed.
RMVJOBSCDE Remove a job schedule entry from the job schedule.
WRKJOBSCDE Display or print job schedule entries.

Job Schedule Entry Examples

This example shows how to submit a job to run program INVENTORY at 11:30 p.m. on the last day of every month except on New Year's Eve.

ADDJOBSCDE JOB(MONTHEND) CMD(CALL INVENTORY) +
SCDDATE(*MONTHEND) SCDTIME('23:30:00') FRQ(*MONTHLY) +
OMITDATE('12/31/93')

Schedule a Job Daily--Example

This example shows how to submit a job to run program DAILYCLEAN every day at 6:00 p.m. The job runs under the user profile SOMEPGMR. This job is not submitted if the system is down or is in restricted state at that time.

ADDJOBSCDE JOB(*JOBD) CMD(CALL DAILYCLEAN)+SCDDAY(*ALL) +
SCDTIME('18:00:00') SCDDATE(*NONE) USER(SOMEPGMR) +
FRQ(*WEEKLY) RCYACN(*NOSBM)

Schedule a Job Weekly--Example

This example shows how to submit a job to run program PGM1 every week starting on 12/17/93 at the current time. Because 12/17/93 is a Friday, the job is submitted every Friday, and it runs under the user profile PGMR1.

ADDJOBSCDE JOB(*JOBD) CMD(CALL PGM1) SCDDATE('12/17/93') +
FRQ(*WEEKLY) USER(PGMR1)


Schedule a Job Every Third Monday and Wednesday--Example

This example shows how to submit a job to run program PGM2 on the third Monday and the third Wednesday at 11:30 p.m. This job will be submitted on the next third Monday or third Wednesday at 11:30 p.m., depending on whether those days have passed already this month. If yesterday was the third Monday, today is the third Tuesday, and tomorrow is the third Wednesday, it will be submitted tomorrow, and then not again until next month.

ADDJOBSCDE JOB(*JOBD) CMD(CALL PGM2) SCDDAY(*MON *WED) +
FRQ(*MONTHLY) SCDDATE(*NONE) RELDAYMON(3) SCDTIME('23:30:00')

Schedule a Job Every First and Third Monday--Example

This example shows how to submit a job to run program PAYROLL on the first and third Monday of every month at 9:00 a.m. The job runs under user profile PAYROLLMGR.

ADDJOBSCDE JOB(PAYROLL) CMD(CALL PAYROLL) SCDDAY(*MON) +
FRQ(*MONTHLY) SCDDATE(*NONE) RELDAYMON(1 3) +
SCDTIME('09:00:00') USER(PAYROLLMGR)

Schedule a Job Every Weekday--Example

This example shows how to submit a job to run PGM4 every weekday at 7:00 p.m.

ADDJOBSCDE JOB(*JOBD) CMD(CALL PGM4) +
SCDDAY(*MON *TUE *WED *THU *FRI) SCDDATE(*NONE) +
SCDTIME('19:00:00') FRQ(*WEEKLY)

Schedule a Job Every Weekday Hourly from 8:00 to 17:00--Example

This can be done two different ways. The first way would be to add a job schedule entry for each hour that the job is to run. An entry similar to the following could be added for the job to run at 8:00 a.m. each day:

ADDJOBSCDE JOB(FILEUPDATE) CMD(CALL PGM(QGPL/FILEUPDATE)) +
FRQ(*WEEKLY) SCDDATE(*NONE) SCDDAY(*MON *TUE *WED *THU *FRI) +
SCDTIME('08:00:00') RCYACN(*SBMRLS) JOBQ(QGPL/QBATCH)

A similar entry could be added to run the job at each following hour from 09:00 a.m. to 17:00. This can be done quickly and easily just by pressing the F9 key after making the initial entry, changing the SCDTIME value and pressing enter. This is perhaps the most direct way to accomplish the hourly job and has the advantage of not keeping a job active for the related job queue all day long.

The alternate to submitting multiple job scheduler entries is to just use the one entry, similar to that shown above, and to have the executed program perform its needed function repeatedly as needed with the appropriate delay in-between executions of the function. The obvious disadvantage of this is that it ties up an active job slot for its job queue all day long. Two code examples will be given below to illustrate possible ways of accomplishing this task:

CALL PGM(QGPL/PGMA) /* INITIAL EXECUTION AT 08:00 */
DLYJOB RSMTIME('09:00:00')
CALL PGM(QGPL/PGMA) /* EXECUTION AT 09:00 */
DLYJOB RSMTIME('10:00:00')
.
.
DLYJOB RSMTIME('17:00:00')
CALL PGM(QGPL/PGMA) /* LAST EXECUTION OF THE DAY */
ENDPGM

The above example uses delays that explicitly delay to resume on the hour for each subsequent hour. This will work fine as long as no single execution of the PGMA program that does the real processing takes longer than one hour. The following example uses a delay of 3600 seconds (60 minutes) between each execution of the PGMA program.

CALL PGM(QGPL/PGMA) /* INITIAL EXECUTION AT 08:00 */
DLYJOB DLY(3600)
CALL PGM(QGPL/PGMA) /* EXECUTION AT 09:00 (APPROXIMATELY) */
DLYJOB DLY(3600)
.
.
DLYJOB DLY(3600)
CALL PGM(QGPL/PGMA) /* LAST EXECUTION OF THE DAY */
ENDPGM

[{"Type":"MASTER","Line of Business":{"code":"LOB57","label":"Power"},"Business Unit":{"code":"BU058","label":"IBM Infrastructure w\/TPS"},"Product":{"code":"SWG60","label":"IBM i"},"Platform":[{"code":"PF012","label":"IBM i"}],"Version":"7.1.0"}]

Historical Number

4363845

Document Information

Modified date:
05 October 2020

UID

nas8N1014597