CL Command Reference - ENDJOB
CL Command List > ENDJOB Reference
Description:
The End Job (ENDJOB) command ends the specified job and any associated inline data files. The job can be on a job queue, it can be active, or it can have already completed running.
You can specify that the application program is given time to control end-of-job processing. If no time is given or if cleanup cannot be performed within the given time, the system performs minimal end-of-job processing, which can include:
. Closing the database files.
. Spooling the job log to an output queue.
. Cleaning up internal objects in the operating system.
. Showing the end-of-job display (for interactive jobs).
. Completing commitment control processing
Before ending the job, you should verify that no logical unit of work is in an in doubt state due to a two-phase commit operation that is in progress. If it is, then the value of the Action if ENDJOB commitment option can greatly impact the ENDJOB processing. For example, if the Action if ENDJOB commitment option is the default value of WAIT, this job will be held up and will not complete its end of job processing until the commitment control operation is completed. This ensures database integrity on all related systems. For specific instructions on how to determine these conditions, and for a description of all the impacts of ending this job under these conditions, see the Backup and Recovery book.
Restrictions: The issuer of the command must be running under a user profile which is the same as the job user identity of the job being ended, or the issuer of the command must be running under a user profile which has job control (*JOBCTL) special authority. This restriction is enforced even when ending the current job.
The job user identity is the name of the user profile by which a job is known to other jobs. It is described in more detail in the Work Management book.
Examples:
Example 1: Ending a Job Immediately
ENDJOB JOB(JOB1) OPTION(*IMMED) SPLFILE(*YES)
This command ends a job named JOB1 immediately. Spooled output produced by the job is deleted; the job log is saved.
Example 2: Saving Spooled Output
ENDJOB JOB(001234/XYZ/JOB2) OPTION(*CNTRLD)
DELAY(50) SPLFILE(*NO)
This command ends a job named 001234/XYZ/JOB2. Spooled output is saved for normal processing by the spooling writer. The job has 50 seconds to perform any cleanup routines, after which it is ended immediately.
Example 3: Removing a Pending Job Log
ENDJOB JOB(543210/ABCDE/JOB3) LOGLMT(0)
This command removes the pending job log for a completed job named 543210/ABCDE/JOB3. This has the same effect as the Remove Pending Job Log (QWTRMVJL) API.
Example 4: Ending the Current Job
ENDJOB JOB(*) OPTION(*IMMED)
This command ends the job in which the command is issued. To exit from a SIGTERM signal handling procedure after the required cleanup has been performed, immediately end the current job. Control may be returned to the command issuer, even though the immediate option has been used. To handle this situation, the program which issued this command should return.