Where allowed to run: All environments (*ALL) Threadsafe: No |
Parameters Examples Error messages |
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:
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.
Top |
Keyword | Description | Choices | Notes |
---|---|---|---|
JOB | Job name | Single values: * Other values: Qualified job name |
Required, Positional 1 |
Qualifier 1: Job name | Name | ||
Qualifier 2: User | Name | ||
Qualifier 3: Number | 000000-999999 | ||
OPTION | How to end | *CNTRLD, *IMMED | Optional, Positional 2 |
DELAY | Controlled end delay time | 1-999999, 30 | Optional, Positional 3 |
SPLFILE | Delete spooled files | *NO, *YES | Optional, Positional 4 |
LOGLMT | Maximum log entries | Integer, *SAME, *NOMAX | Optional |
ADLINTJOBS | Additional interactive jobs | *NONE, *GRPJOB, *ALL | Optional |
DUPJOBOPT | Duplicate job option | *SELECT, *MSG | Optional |
Top |
Specifies the qualified job name of the job to be ended.
This is a required parameter.
Single values
Qualifier 1: Job name
Qualifier 2: User
Qualifier 3: Number
Note: If no user name or job number is specified, all jobs currently in the system are searched for the job name. If more than one occurrence of the specified name is found, a qualified job name must be provided either explicitly or through the selection display. Refer to the Duplicate job option (DUPJOBOPT) parameter for more information.
Top |
Specifies whether the job ends immediately or in a controlled manner that lets the application program perform end-of-job processing. In either case, the system performs certain job cleanup processing.
Note: The *IMMED value might cause undesirable results if data has been partially updated. This value should be used only after a controlled end has been attempted unsuccessfully.
Note: When a SIGTERM signal handler is running during the immediate ending of a job, an ENDJOB command with OPTION(*IMMED) can be used to end the SIGTERM signal handler. This is only allowed if the SIGTERM signal handler has already had at least two minutes to run.
Top |
Specifies the amount of time (in seconds) allowed for the job to complete its cleanup processing during a controlled end. If the cleanup is not completed before the end of the delay time, the job is ended immediately. (Only system cleanup is performed.)
The delay time does not start until the job becomes active if the job is suspended because of one of the following conditions:
Note: This parameter is valid only when OPTION(*CNTRLD) is specified.
Top |
Specifies whether spooled output files created by this job are kept for normal processing or deleted. Regardless of whether the spooled files are deleted, the job logs are kept.
Top |
Specifies the maximum number of entries in the message queue of the job being ended that are written to the job log. This parameter can be used to limit the number of messages written to the job log printer file, QPJOBLOG, for a job that ends.
The value specified on this parameter can change the logging limit of the job even if the job is already ending or the job has already ended. The following are examples of how the logging limit can be changed:
Top |
Specifies whether the additional interactive jobs associated with the job specified in the Job name (JOB) parameter are ended.
Top |
Specifies the action taken when duplicate jobs are found by this command.
Top |
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.
Top |
*ESCAPE Messages
Top |