End a stuck IBM i job: ENDJOB *CNTRLD, *IMMED and ENDJOBABN
End an IBM i job from WRKACTJOB or with ENDJOB. Try a controlled end first, then *IMMED; ENDJOBABN is the last resort, only after 10 minutes.
A batch job loops, or an old 5250 session is stuck and holding a device or a lock. On IBM i you end it with the End Job (ENDJOB) command, in steps from gentle to forceful.
Find the job
Every job has a three-part name: number/user/name, for example 001234/USER1/QPADEV0004. For an interactive session the job name is the display device name. See IBM i sessions explained: display device, interactive job and sign-on.
WRKACTJOBlists active jobs. Type 4 (End) next to a job, or 5 to work with it first.WRKUSRJOB(Work with User Jobs) lists jobs by user.
Step 1: a controlled end
ENDJOB JOB(001234/USER1/QPADEV0004) OPTION(*CNTRLD) DELAY(30)
*CNTRLD is the default. The program gets time to clean up; a program that handles the SIGTERM signal receives it. If the job has not finished after DELAY seconds (30 by default), the system ends it immediately, and only the system's own cleanup is done.
Step 2: an immediate end
ENDJOB JOB(001234/USER1/QPADEV0004) OPTION(*IMMED)
The job ends at once, and only the system's end-of-job cleanup runs, which can still take several minutes. IBM says to use *IMMED only after a controlled end has failed, because data that was being updated may be left half done.
Step 3: ENDJOBABN, only if *IMMED does not finish
ENDJOBABN JOB(001234/USER1/QPADEV0004)
End Job Abnormal is for a job that is still ending after an immediate end. It is not allowed until 10 minutes after the immediate end started. It skips most end-of-job processing, including writing the job log and the end-of-job display, gives the rest five minutes, and then forces the job to end.
It has side effects. IBM lists them:
- The next system end is marked abnormal, and the next IPL runs extra cleanup.
- Some resources the job used may stay unavailable until the next IPL.
- The job log is not written until the next IPL; the job shows
JOBLOG PENDING, andDSPJOBLOGcan still show it. - It can be run only once per job.
Use it only when another job or the system needs what the stuck job holds.
Useful options and messages
SPLFILE(*YES)also deletes the job's spooled output; the job log is kept. The default,*NO, keeps it.ADLINTJOBS(*ALL)also ends the other interactive jobs on the same workstation, such as a second job opened from the System Request menu.ENDJOB JOB(*)ends the job you are typing in.- CPF1344 "Not authorized to control job": you can end your own jobs; ending another user's needs job control (
*JOBCTL) special authority. - CPF1362 "Job ... has completed": it has already ended.
- CPF1363 or CPF1361: it is already ending, controlled or immediate.
Related
- 5250 device name already in use: find the old session and free the name
- IBM i CL basics
- The IBM i System Request menu
- Why an IBM i session ends or signs off when it sits idle
- IBM i job in MSGW status: find the message and reply to it
- IBM i job log missing or empty: CHGJOB LOG, LOGCLPGM and pending job logs