iCan Blog Archive

I received a question regarding the QTEMP library, prompted by the post Understanding Disk Space Usage. I thought sharing the question and providing the answer in this week’s blog would be helpful for everyone, as well as expanding upon how the system views and manages QTEMP when it comes to disk space usage.

The email I received was from John Knox:

When it comes to temporary storage, the value in the job run attributes in WRKJOB only shows temp storage used by an application, presumably for working storage, etc. What it doesn’t show is space used in the QTEMP library for that job. Several times this has been an issue for us because an application creates a temporary file or user space in QTEMP and the file gets very large and we have a difficult time determining which job is the offender. My intention was to create a utility to scan all active jobs and display a screen showing the sizes of QTEMP for each job. However after much research there doesn’t appear to be an easy way to query the size of QTEMP libraries for the jobs on the system unless there is an API I haven’t found yet.

So my real question is, do you know of any way to query the size of QTEMP for each job on the system?

First, let me explain how the system accounts for storage in the QTEMP library.

The QTEMP library itself is created out of permanent storage; any objects that you create in QTEMP –work files, data areas, message queues, or whatever — are also permanent objects. When the job ends, the system deletes the objects in the QTEMP library. Because QTEMP itself and the objects created into QTEMP are permanent objects, the storage they consume is tracked as permanent; it is charged to the user profile and the objects in QTEMP can be manipulated like any other object — saved and restored, renamed, moved to other libraries, etc. The library name, QTEMP, reflects the fact that it is associated with a job only when the job is active. Perhaps it would have been better if IBM would have called QTEMP the “QJOB” library.

So back to the question asked – how can an administrator determine the size of QTEMP libraries for the system and determine if there are jobs with QTEMP libraries consuming a lot of disk space?

There are a few ways to do this:

  1. The easiest way to find the size of any job’s QTEMP library is to use the QSYS2.Active_Job_Info() service, with Detailed_Info => QTEMP. This support was added 7 years after this post was originally published.
  2. You can display your own job and view your own QTEMP. For your own job, you can do a DSPLIB QTEMP OUTPUT(*PRINT) which will give you the total size of the library at the bottom of the listing.  You can use the Retrieve Library Description API to get the size of your job’s QTEMP library.
  3. You can work with an active job (WRKJOB) and look at the job’s library list, which will include QTEMP. You can then display the contents of the QTEMP library; this is a manual approach and you have to calculate the total size from the displayed list.
  4. You can use the Open List of Objects API to get a list of objects in another job’s QTEMP library.  You need to call the API using optional parameter group 1 and specify the other job. The program would also need to sum the sizes of all objects returned to get the total size. 
  5. Extending upon option 3, you can use the Open List of Jobs API to get a list of all active jobs and then for each job, use the Open List of Objects API for QTEMP. Be aware that the jobs can start or end after the Open List of Jobs API returns its results.
  6. You can use the Call Job Interrupt Program Exit Program to run a program in a different job which could be a program to determine the size of the QTEMP library for that job. More was written about this exit program in Interrupt Job Exit Program – Invoking a Program in Another Job.

This blog post was edited for currency on February 17, 2020.

This blog post was originally published on IBMSystemsMag.com and is reproduced here by permission of IBM Systems Media.