Operations / scheduling
Let the system run jobs on time.
A job schedule entry submits a job when its date and time arrive. The system reply list answers the same inquiry messages every time.
What a job schedule entry is
IBM i keeps one system job schedule, QUSRSYS/QDFTJOBSCD. An entry holds the CL command to run, its frequency and time, the job description, job queue, user profile and message queue, plus housekeeping such as omitted dates and a recovery action. Entries survive an IPL, and the scheduler submits each due entry to its job queue. Learn400 logs each submission in QHST.
The commands are ADDJOBSCDE, CHGJOBSCDE, RMVJOBSCDE, HLDJOBSCDE, RLSJOBSCDE and WRKJOBSCDE. Adding or changing entries needs *CHANGE authority to the job schedule object QUSRSYS/QDFTJOBSCD; the examples below sign on as QSECOFR.
Create a weekly entry
CRTLIB APP TYPE(*TEST)
ADDJOBSCDE JOB(NIGHTLY) CMD(CALL PGM(APP/NIGHTLY)) FRQ(*WEEKLY) +
SCDDAY(*MON *TUE *WED *THU *FRI) SCDTIME(230000) TEXT('Weeknight batch')
WRKJOBSCDE
The list shows Job, Status, Date, Time, Frequency, Recovery and Next Submit. F11 switches to the job queue data: job queue, job description, user and message queue. F6 adds an entry.
A monthly entry runs either on a date or on a day of the week, never both. SCDDATE(*MONTHEND) runs on the last day of every month. For "the last Friday", schedule by day: SCDDATE(*NONE), SCDDAY(*FRI) and RELDAYMON(*LAST), the last occurrence of that day in the month (1 to 5 pick the first to fifth).
ADDJOBSCDE JOB(MONTHEND) CMD(CALL PGM(APP/MONTHEND)) FRQ(*MONTHLY) +
SCDDATE(*MONTHEND) SCDTIME(010000)
ADDJOBSCDE JOB(LASTFRI) CMD(CALL PGM(APP/LASTFRI)) FRQ(*MONTHLY) +
SCDDATE(*NONE) SCDDAY(*FRI) RELDAYMON(*LAST) SCDTIME(060000)
Use OMITDATE for dates the entry must skip, typed in the job's date format (MDY with / separators on a new job), and RCYACN to say what an IPL should do with an occurrence that was missed while the system was down. *SBMRLS submits it, *SBMHLD submits it held on its job queue and *NOSBM skips it. Each occurrence is handled once, however many were missed.
CHGJOBSCDE JOB(NIGHTLY) OMITDATE('12/25/26') RCYACN(*SBMHLD)
Hold, change, release and remove
HLDJOBSCDE JOB(NIGHTLY)
RLSJOBSCDE JOB(NIGHTLY)
CHGJOBSCDE JOB(NIGHTLY) SCDTIME(220000)
RMVJOBSCDE JOB(MONTHEND)
RMVJOBSCDE JOB(LASTFRI)
WRKJOBSCDE OUTPUT(*PRINT) PRTFMT(*FULL)
WRKSPLF
On the WRKJOBSCDE list, 2 changes an entry, 3 holds it, 4 removes it with confirmation, 5 displays its details, 6 releases it, 8 works with its last submission and 10 submits it now. A held entry stays in the schedule with status HLD and its occurrences are skipped.
The system reply list
The reply list is a numbered list of answers for inquiry messages. A job with INQMSGRPY(*SYSRPYL) checks it before waiting for an operator. The list ships with entries 10 CPA0700, 20 RPG0000, 30 CBE0000 and 40 PLI0000, each replying D with a dump. Maintain it with ADDRPYLE, CHGRPYLE, RMVRPYLE and WRKRPYLE; changing the list needs *JOBCTL special authority.
ADDRPYLE SEQNBR(12) MSGID(CPA4002) RPY(*RQD) CMPDTA('QSYSPRT' 21)
ADDRPYLE SEQNBR(14) MSGID(CPA4002) RPY(G)
ADDRPYLE SEQNBR(15) MSGID(APP0100) RPY(*DFT)
WRKRPYLE
CHGRPYLE SEQNBR(14) RPY(I) DUMP(*YES)
RMVRPYLE SEQNBR(14)
CHGJOB INQMSGRPY(*SYSRPYL)
Entries are checked in ascending sequence order. A message ID such as RPG0000 covers the whole RPGxxxx range, and *ANY matches every message. CMPDTA compares message substitution data from the 1-based start position. RPY may be *DFT for the message default, *RQD to keep waiting for a reply, or the reply text itself. DUMP(*YES) writes a QPSRVDMP spooled dump before replying.
WRKRPYLE outside a display prints the list. Inside a display it offers 2=Change, 4=Remove and F6=Add. The tutorial Schedules and the reply list builds a small program that asks a question and lets the reply list answer it.
What is not supported yet
- Entries can be added and changed with the commands and the WRKJOBSCDE panel, but there is no QWCLSCDE API and no outfile support for WRKJOBSCDE.
- ADDJOBSCDE assigns entry numbers itself; it has no ENTNBR parameter.
- DUMP(*YES) writes a readable emulator job dump in QPSRVDMP, not IBM's native formatted dump layout.
- CMPDTA is stored without trailing blanks, so a comparison that depends on intentional trailing blanks cannot be made.
See also the command reference for
ADDJOBSCDE,
WRKJOBSCDE and
WRKRPYLE.