Take Advantage of Job Log Pending
IBM i expert Dawn May writes why you may want to consider this option for your job logs.
By Dawn May05/14/2020
In the blog, Take Advantage of the Job Log Server, I wrote about the job log server and recommended changing the system value QLOGOUTPUT to *JOBLOGSVR rather than the default of *JOBEND. This week I want to review job log pending and discuss reasons why you may want to consider this option for your job logs.
IBM i stores job log messages in an internal job structure that is called the “job message queue.” The job message queue is a permanent job structure (survives an IPL) that stores the messages sent to the job log. The “traditional” behavior is for job log messages to be written the QPJOBLOG spooled file when the job ends.
Writing a job log to a spooled file consumes system resources—primarily CPU and I/O. There is also a system limit on the maximum number of spooled files in the system, and spooled job logs contribute to the total number of spooled files. Many times, job logs are kept “just in case” something goes wrong. If no errors occur, these job logs may never be reviewed.
Rather than writing job logs to spooled files, job log pending allows you to keep the job logs in the internal form that is used when a job is active. No additional system resources are required to keep a job log in pending form other than the job structure used to store information about the ended job, but the permanent job structures are also used for jobs that have ended with spooled output, so there is no difference between the two.
Job log pending is controlled by the Job Log Output system value (QLOGOUTPUT), or the Job Log Output attribute on job descriptions. I generally recommend setting the system value at *JOBLOGSVR and use the LOGOUTPUT parameter on the job description. I also recommend using *PND for job logs you don’t expect to need as spooled files.
You can still access the job log when using *PND, but you just have to change your approach. Many of us use WRKSPLF to find all our spooled output, or WRKOUTQ QEZJOBLOG to find job logs. Below are several ways to find pending job logs; the first three ways listed below are ways you display job logs for active jobs.
- WRKJOB command, option 10 (job log) (as opposed to WRKJOB option 4)
- DSPJOBLOG command will display a pending job log.
- QSYS2.JOBLOG_INFO() service will retrieve messages from a pending job log.
- WRKJOBLOG command, by default, will display all the pending job logs for the current date, but you can specify timeframes as well as job names, including generic job names. WRKJOBLOG also allows you to find spooled job logs.
- DSPJOBLOG with OUTPUT(*PRINT). Note that the QPJOBLOG spooled file will be associated with the job that issued the DSPJOBLOG command.
- CHGJOB with LOGOUTPUT(*JOBEND) or (*JOBLOGSVR) will generate the spooled job log and the job is will no longer have a pending job log.
- ENDJOB command with LOGLMT(0); for example:
ENDJOB JOB(543210/JobName/JobUser) LOGLMT(0)
- WRKJOBLOG has an option to delete a pending job log or F13 which will delete all pending job logs
- The Remove Pending Job Log (QWTRMVJL) API
- The system’s cleanup facility will clean up pending job logs just as it does for spooled job logs
The QSYS2.JOB_INFO service can also be used to retrieve information about jobs that have pending job logs. The job status is *OUTQ and the JOB_LOG_PENDING column will be YES.
Below are some references for further reading:
Job Log Pending in the Knowledge Center
Removing Pending Job Logs IBM Support document
Jobs in Job Log Pending Status IBM Support document
Best Practices for Managing IBM i Jobs and Output IBM Redpaper
Dawn May is an IBM i consultant. She owns Dawn May Consulting, LLC in the Greater Boston area. Dawn is a former IBM senior technical staff member.