How can I Clean, Archive or Delete old IBM i Spool Files?

  • Home
  • /
  • Blog
  • /
  • How can I Clean, Archive or Delete old IBM i Spool Files?

June 10, 2024

What are Spool Files?

Spooled files on an IBM i System (AS400/iSERIES) are a way to manage output data for printing or processing. They can contain basic text layouts of printed pages, or complex PDF style data streams.

Here’s how they work:

  • Spooling Function: Spooling (short for “simultaneous peripheral operations online”) saves data in a spooled file for later processing or printing. It’s similar to how tape files or other device files work.
  • Purpose: Spooled files hold output data until it can be printed by an external device, such as a printer.
  • Collection of Data: A spooled file collects data from a device (e.g., an application program) until a program or device is ready to process it. Programs can read from or write to a spooled file as if it were an actual device.

So, IBM i Spooled Files are virtual printouts, helping you manage input and output operations efficiently in a multi-user environment.

Clean, Archive or Delete IBM i Spool Files

To clean up or delete old spooled files on an IBM i system, you have a few options.

The DELETE_OLD_SPOOLED_FILES procedure deletes spooled files according to filtering criteria. It can optionally return a preview of the files that meet the filtering criteria without performing the delete.

Using the DELETE_OLD_SPOOLED_FILES Procedure (SQL):

The DELETE_OLD_SPOOLED_FILES procedure allows you to delete spooled files based on filtering criteria. It can also provide a preview of the files that meet the criteria without actually deleting them.

You can specify the following parameters:

  • DELETE_OLDER_THAN: A timestamp value defining the starting point for deleting spooled files (default is CURRENT TIMESTAMP – 3 MONTHS).
  • P_OUTPUT_QUEUE_NAME: Specify an output queue name (default is *ALL).
  • PREVIEW: Indicates whether to return a result set or delete the spooled files (default is NO).

Example usage:

To preview spooled files older than 30 days in output queue QPRINT:

CALL SYSTOOLS.DELETE_OLD_SPOOLED_FILES (
     DELETE_OLDER_THAN => CURRENT DATE - 30 DAYS,
     P_OUTPUT_QUEUE_NAME => 'QPRINT',
     PREVIEW => 'YES'
);

To perform the actual delete of spooled files older than 30 days in output queue QPRINT:

CALL SYSTOOLS.DELETE_OLD_SPOOLED_FILES (
     DELETE_OLDER_THAN => CURRENT DATE - 30 DAYS,
     P_OUTPUT_QUEUE_NAME => 'QPRINT'
);

Here it is inaction:

systools.delete_old_spooled_files

To perform the delete of spooled files older than 90 days on the entire system (all output queues):

CALL SYSTOOLS.DELETE_OLD_SPOOLED_FILES (
     DELETE_OLDER_THAN => CURRENT DATE - 90 DAYS
);

Using the WRKSPLF Command (Interactive):

If you prefer an interactive approach, you can use the WRKSPLF command.

Prompt the command, specify the user ID, and then select the spooled files you want to delete (status RDY, CLO, HLD, or SAV).

Custom Programs or Commands:

You can create your own custom programs or commands to delete spooled files based on specific criteria.

Remember to ensure proper authorization and test any deletion process in a safe environment before applying it to production data.

Important considerations when cleaning up IBM i Splfs!

Need to save your IBM i Spool Files ?

NickLitten


IBM i Software Developer, Digital Dad, AS400 Anarchist, RPG Modernizer, Shameless Trekkie, Belligerent Nerd, Englishman Abroad and Passionate Eater of Cheese and Biscuits.

Nick Litten Dot Com is a mixture of blog posts that can be sometimes serious, frequently playful and probably down-right pointless all in the space of a day.

Enjoy your stay, feel free to comment and remember: If at first you don't succeed then skydiving probably isn't a hobby you should look into.

Nick Litten

related posts:

{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}

Subscribe NOW
7-day free trial

Take This Course with ALL ACCESS

Unlock your Learning Potential with instant access to every course and all new courses as they are released.
 [ For Serious Software Developers only ]

Online Learning for IBM i Software Technology Professionals

“The more that you read, the more things you will know. The more that you learn, the more places you’ll go.” – Dr. Seuss

>