MainframeMaster

JCL Tutorial

JES2 Commands

Progress0 of 0 lessons

What is JES2?

JES2 (Job Entry Subsystem 2) is a component of the z/OS operating system that receives jobs into the operating system, schedules them for processing, and manages their output processing. It's responsible for spooling, job queuing, and controlling the entire lifecycle of batch jobs in the mainframe environment.

JES2 commands allow operators and system programmers to monitor and control batch jobs, manage spool resources, and interact with the job processing environment. These commands are essential for day-to-day operations in a mainframe computing environment.

JES2 Command Format

JES2 commands begin with a dollar sign ($) prefix, followed by a verb and potentially additional operands. The basic format is:

text
1
$verb operand,parameter=value

For example, to display job number 123: $D J123

Commands can be entered at the console, through automated facilities, or via the SDSF (System Display and Search Facility) interface.

Essential JES2 Commands

CommandDescriptionExample
$D JDisplay job information$D J123 - Display info for job 123
$C JCancel a job$C J123 - Cancel job 123
$H JHold a job$H J123 - Hold job 123
$A JRelease a held job$A J123 - Release job 123
$P JPurge job output$P J123 - Purge job 123 output
$T JModify job attributes$T J123,CLASS=A - Change job 123 to class A
$S JStart a job$S J123 - Start job 123
$O JRelease job output$O J123 - Release output for job 123

JES2 Command Categories

1. Job Control Commands

Commands for managing individual jobs:

Display Jobs with Wildcards

text
1
2
3
4
$D J(PAY*) /* Display all jobs starting with PAY */ $D J(*),JOBNAME=PAY* /* Alternative syntax */ $D J(*),STATUS=HELD /* Display all held jobs */ $D J(*),CLASS=A /* Display all class A jobs */

Cancel Jobs with Specific Criteria

text
1
2
3
$C J(*),AGE>1440 /* Cancel jobs older than 1 day (1440 minutes) */ $C J(*),JOBNAME=TEST* /* Cancel all jobs starting with TEST */ $C J(*),C=X,SECLABEL=SECRET /* Cancel class X jobs with security label SECRET */

2. Initiator Commands

Commands for managing job initiators, which are the processes that execute batch jobs:

text
1
2
3
4
5
6
7
$D I /* Display all initiators */ $D I1-5 /* Display initiators 1 through 5 */ $S I1-3 /* Start initiators 1 through 3 */ $P I4 /* Stop initiator 4 (after current job) */ $Z I5 /* Halt initiator 5 (immediately) */ $T I1,C=A /* Set initiator 1 to process class A jobs */ $T I2,C=(A,B,C) /* Set initiator 2 to process classes A, B, and C */

3. Spool Management Commands

Commands for managing JES2 spool volumes:

text
1
2
3
4
5
$D SPOOL /* Display spool volume status */ $D SPOOLDEF /* Display spool definitions */ $T SPOOL(SPOOL1),HALT /* Halt allocation on SPOOL1 */ $P SPOOL(SPOOL2) /* Drain spool volume SPOOL2 */ $S SPOOL(SPOOL3) /* Start using spool volume SPOOL3 */

4. Output Management Commands

Commands for managing job output and printers:

text
1
2
3
4
5
6
7
8
9
$D O J123 /* Display output for job 123 */ $O J123,ALL /* Release all output for job 123 */ $P O J123 /* Purge output for job 123 */ $D PRT1 /* Display printer 1 status */ $S PRT2 /* Start printer 2 */ $P PRT3 /* Stop printer 3 (after current output) */ $I PRT4 /* Interrupt printer 4 */ $F PRT5,C /* Forward printer 5 to next job */ $B PRT6 /* Backward restart printer 6 */

5. JES2 System Commands

Commands for controlling the JES2 subsystem itself:

text
1
2
3
4
5
6
7
8
$P JES2 /* Perform orderly shutdown of JES2 */ $S JES2 /* Start JES2 (if it's the primary subsystem) */ $E JES2 /* Restart JES2 after failure */ $D ACTIVATE /* Display activation information */ $ACTIVATE LEVEL=z22 /* Activate z/OS 2.2 JES2 functions */ $D LIMITS /* Display resource limits */ $D MEMBER /* Display JES2 member information (in a multi-access spool configuration) */ $D MASDEF /* Display multi-access spool settings */

Command Modifiers and Parameters

JES2 commands support a wide range of modifiers and parameters that allow for precise control:

ParameterDescriptionExample
JOBNAME or NAMEJob name filter$D J(*),NAME=PAY*
CLASS or CJob class$D J(*),C=A
PRIORITY or PJob priority$T J123,P=9
SYSAFFSystem affinity$T J123,SYSAFF=(SYS1)
STATUSJob status filter$D J(*),STATUS=ACTIVE
AGEJob age in minutes$D J(*),AGE>60
OWNERJob owner (submitter)$D J(*),OWNER=USER*
USERID or USERID=User ID filter$D J(*),USERID=SYSPROG
HELD or HHeld status filter$D J(*),H=YES

Common JES2 Command Scenarios

Scenario 1: Finding and Canceling a Problematic Job

text
1
2
3
4
5
6
7
8
9
10
11
/* Step 1: Find all jobs from a specific user */ $D J(*),OWNER=JOHN /* Step 2: Get details about a specific job */ $D J12345,LONG /* Step 3: Cancel the job if necessary */ $C J12345,ARMRESTART /* Step 4: Verify job status after cancel */ $D J12345

The ARMRESTART parameter attempts to invoke automatic restart management for the job if it's defined to ARM.

Scenario 2: Managing Initiators for Workload Balancing

text
1
2
3
4
5
6
7
8
9
10
11
/* Step 1: Check current initiator status */ $D I /* Step 2: Check backlog of jobs by class */ $D JQ,READY,CLASS=A $D JQ,READY,CLASS=B /* Step 3: Modify initiators to balance workload */ $T I1,C=(A,B) /* Add class B to initiator 1 */ $T I2,C=(B,A) /* Rearrange priority for initiator 2 */ $S I3-5 /* Start additional initiators */

Scenario 3: Handling Output for a Critical Job

text
1
2
3
4
5
6
7
8
9
10
11
/* Step 1: Find the job output */ $D O J12345 /* Step 2: Set output priorities and destination */ $T O J12345,OUTDISP=(WRITE,KEEP),PRIORITY=9 /* Step 3: Release output to specific printer */ $O J12345,PRT3 /* Step 4: Verify output was processed */ $D O J12345

Scenario 4: JES2 Shutdown and Restart

text
1
2
3
4
5
6
7
8
9
10
11
12
13
14
/* Step 1: Display active jobs before shutdown */ $D A /* Step 2: Stop initiators to prevent new jobs from starting */ $P I(*) /* Step 3: Wait for running jobs to complete */ $D A /* Repeat until no jobs are active */ /* Step 4: Shutdown JES2 */ $P JES2 /* Later: Restart JES2 */ $S JES2

Best Practices for JES2 Command Usage

  • Use specific identifiers: Whenever possible, use specific job IDs rather than wildcards to avoid unintentional impact on multiple jobs.
  • Verify before action: Always use display commands ($D) to verify the target before using action commands like cancel ($C) or modify ($T).
  • Document command usage: Keep a log of significant JES2 commands issued, especially during problem troubleshooting or system maintenance.
  • Be cautious with system-wide commands: Commands that affect the entire JES2 subsystem should be used with extreme caution and proper authorization.
  • Use SDSF when available: For most operations, SDSF provides a friendlier interface to JES2 commands with additional safeguards.
  • Understand security implications: Be aware that JES2 commands can be restricted by security products like RACF, and ensure proper authorization.

JES2 Commands Exercises

Exercise 1: Job Display and Control

Write the JES2 commands to: (1) Display all jobs with names starting with "PAY", (2) Hold all jobs in class P, (3) Change the class of job 1234 to A, and (4) Cancel job 5678 with a dump.

Exercise 2: Initiator Management

Write the JES2 commands to: (1) Display all initiators, (2) Stop initiators 1 through 3, (3) Modify initiator 4 to process classes A, B, and C, and (4) Start initiators 5 through 8.

Exercise 3: Output Management

Write the JES2 commands to: (1) Display all output for job 1234, (2) Set the output priority to 9, (3) Release the output to printer PRT1, and (4) Verify that the output was processed.

Frequently Asked Questions

Test Your Knowledge

1. Which JES2 command is used to display information about a job?

  • $SHOW JOB
  • $LIST JOB
  • $D JOB
  • $INFO JOB

2. What command would you use to release a held job with ID 1234?

  • $R 1234
  • $A J1234
  • $REL 1234
  • $FREE J1234

3. Which command is used to cancel a job that is currently executing?

  • $T J1234,CANCEL
  • $CAN J1234
  • $C J1234
  • $DELETE J1234

4. What does the "$P JES2" command do?

  • Purges all jobs in the system
  • Puts JES2 in pause mode
  • Initiates an orderly shutdown of JES2
  • Prioritizes JES2 processing

5. Which command would you use to display all jobs with a name starting with "PAY"?

  • $D J(PAY*)
  • $S J=PAY*
  • $L J PAY*
  • $F J PAY*