Debug a running job

You can debug a job that is already running if you know what statements the job will run.

For example, you may want to debug a running program if the job is looping or the job has not yet run a program that is to be debugged. The following steps allow you to debug a running job:

  1. Use the Work with Active Jobs (WRKACTJOB) command to find the job that is running. When the display appears, enter option 5 next to the job to obtain the qualified job name.
  2. Enter the Start Service Job (STRSRVJOB) command as follows:
    STRSRVJOB JOB(qualified-job-name)
  3. Enter the Start Debug (STRDBG) command. (Entering the command does not stop the job from running.)
    Note: You can use the Display Debug (DSPDBG) command to show the call stack. However, unless the program is stopped for some reason, the stack is correct only for an instant, and the program continues to run.
  4. If you know a statement to be run, enter the Add Breakpoint (ADDBKP) command to stop the job at the statement.

    If you do not know what statements are being run, do the following:

    1. Enter the Add Trace (ADDTRC) command.
    2. After a short time, enter the Remove Trace (RMVTRC) command to stop tracing the program.
    3. Enter the Display Trace Data (DSPTRCDTA) command to show what statements have processed. Use the trace data to determine which data statements to process next (for example, statements inside a program loop).
    4. Enter the Add Breakpoint (ADDBKP) command to stop the job at the statement.
  5. Enter the desired debug commands when the program is stopped at a breakpoint.
Related information
Display Debug (DSPDBG) command
Display Trace Data (DSPTRCDTA) command
Add Breakpoint (ADDBKP) command
Add Trace (ADDTRC) command
CL command finder