• The Four Hundred
  • Subscribe
  • Media Kit
  • Contributors
  • About Us
  • Contact
Menu
  • The Four Hundred
  • Subscribe
  • Media Kit
  • Contributors
  • About Us
  • Contact
  • Automatically Deleting Spooled Files through Expiration Dates

    March 23, 2011 Hey, Joe

    Last year, I stumbled on a cool method for automatically deleting spooled files. When you create a spooled file, you can set the number of days that you want to keep that file on your system. Then once a night, you can submit a job that runs the Delete Expired Spooled Files (DLTEXPSPLF) command that will automatically delete expired spooled files. You should try it.

    –Peter

    After working with the Power i and its antecedents for almost 30 years, I always find it interesting when somebody shows me something valuable that I haven’t used before. DLTEXPSPLF is a simple command that automatically removes all expired spooled files from all the system Auxiliary Storage Pools (ASPs) or the system ASP on your iSeries, System i, and Power i partitions.

    DLTEXPSPLF takes a little planning because spooled files don’t just expire on their own accord. Rather, you have to configure each spooled file with its own expiration date for later removal. This can be done before or after the spooled file is created.

    To really understand DLTEXPSPLF, it’s best to look at an example. Let’s say that we want to set up all our INVOICE spooled files to automatically be deleted from the system after 30 days. We can easily do this by making the following changes.

    1.Change the printer file that is used to create your target spooled file, so that it includes a target expiration period for newly created invoices–Let’s assume you’re using a third-party accounting package that uses a printer file called INVOICE to create all your invoice spooled files. If we want to designate that all INVOICE spooled files will expire after 30 days, we can change the EXPIRATION DATE FOR FILE (EXPDATE) parameter to *DAYS and the DAYS UNTIL FILE EXPIRES (DAYS) parameter to 30 days inside the INVOICE printer file. For this modification, we can simply run the following CHANGE PRINTER FILE (CHGPRTF) command.

    CHGPRTF FILE(INVOICE) EXPDATE(*DAYS) DAYS(30)
    

    This command changes the printer file immediately so all new invoices will automatically be tagged with an expiration date of 30 days past their creation dates. Note that this will work for any spooled files that are created through an associated printer file. Altering source printer file parameters can serve as an easy way to set different expiration dates for different types of spooled files.

    2. Set up a daily job to delete all spooled files that have expired during the previous day–This can be done either through IBM‘s job scheduler or through a third-party i/OS job scheduler such as Help/Systems’ Robot/SCHEDULE. Run DLTEXPSPLF this way in your scheduled job if you want to delete expired spooled files in all of your ASPs.

    DLTEXPSPLF ASPGRP(*ALL)
    

    Run DLTEXPSPLF this way if you only want to delete expired spooled files in your system ASP (ASP 1).

    DLTEXPSPLF ASPGRP(*SYSBAS)
    

    Spooled files always expire at 23:59:59 military time on their expiration date. So if you run DLTEXPSPLF once a day, it will delete all the spooled files that expired the day before.

    To add an entry to the IBM job scheduler for running DLTEXPSPLF on a daily schedule, you can run the following ADD JOB SCHEDULER ENTRY (ADDJOBSCDE) command that IBM lists in its i5/OS V5R4 Information Center entry on DLTEXPSPLF.

    ADDJOBSCDE   JOB(DLTEXPSPLF)  CMD(DLTEXPSPLF  ASPGRP(*ALL))            
    FRQ(*WEEKLY)  SCDDATE(*NONE)  SCDDAY(*ALL)SCDTIME(010000)  
    JOBQ(QSYS/QSYSNOMAX) TEXT('DELETE EXPIRED SPOOLED FILES SCHEDULE ENTRY')
    

    And that’s all there is to automatically deleting your job logs. If you want to add any other types of spooled files to your automatic deletion schedule, change their print file attributes, provided you can find the print file they are created from.

    You can also change spooled file expiration dates on the fly by running the CHANGE SPOOLED FILE ATTRIBUTES (CHGSPLFA) command to modify the expiration dates of files as they are created or as they sit in an output queue. To change the expiration date on a recently created spooled file to 30 days, all you have to do is gather the relevant spooled file information and run the following CHGSPLFA command.

    CHGSPLFA   FILE(spooled file name) JOB(job number/user name/job name) 
    SPLNBR(spooled file number) EXPDATE(*DAYS) DAYS(30)
    

    If you don’t want to mess around with changing expiration dates on the fly, you can create your own program to change the expiration dates for all spooled files in an output queue. A few years, I wrote a program called MOVSPLF that was used to move spooled files from one output queue to another. This program creates a work file of all the spooled files in a particular output queue and uses CHGSPLFA to move each spooled file to another output queue. With a little modification, you can easily change MOVSPLF to set expiration dates for all the spooled files in an output queue. Click here to check out the architecture and code for the MOVSPLF program.

    –Joe

    RELATED STORY

    Admin Alert: Automatically Moving Printed Spooled Files Between Output Queues



                         Post this story to del.icio.us
                   Post this story to Digg
        Post this story to Slashdot

    Share this:

    • Share on Reddit (Opens in new window) Reddit
    • Share on Facebook (Opens in new window) Facebook
    • Share on LinkedIn (Opens in new window) LinkedIn
    • Share on X (Opens in new window) X
    • Email a link to a friend (Opens in new window) Email

    Tags:

    Sponsored by
    Lightedge

    Your IBM Power Cloud Strategy Should Start With “Why?”

    Moving IBM i to the cloud isn’t just an infrastructure decision.

    A hardware refresh, data center exit, IBM i skills gap, disaster recovery requirement, or broader cloud initiative can each lead to a very different architecture.

    At Lightedge, we start by understanding what you’re trying to accomplish. Then we look at the workload, application dependencies, resiliency requirements, operating model, and long-term strategy to determine where that workload belongs.

    Managed IBM Power cloud? IBM Power Virtual Server? DR in the cloud? A hybrid architecture connecting IBM Power with AWS or Azure?

    There isn’t one right answer for every IBM i environment.

    Start with the business requirement. Understand the workload. Then decide where it belongs.

    Explore IBM Power cloud, managed services, and hybrid solutions from Lightedge.

    Share this:

    • Share on Reddit (Opens in new window) Reddit
    • Share on Facebook (Opens in new window) Facebook
    • Share on LinkedIn (Opens in new window) LinkedIn
    • Share on X (Opens in new window) X
    • Email a link to a friend (Opens in new window) Email

    Sponsored Links

    SEQUEL Software:  FREE Webinar: Overcoming query limits with SEQUEL. March 23
    Northeast User Groups Conference:  21th Annual Conference, April 11 - 13, Framingham, MA
    looksoftware:  Integrate IBM i apps with web services. FREE on-demand webinar and white paper!

    IT Jungle Store Top Book Picks

    BACK IN STOCK: Easy Steps to Internet Programming for System i: List Price, $49.95

    The iSeries Express Web Implementer's Guide: List Price, $49.95
    The iSeries Pocket Database Guide: List Price, $59
    The iSeries Pocket SQL Guide: List Price, $59
    The iSeries Pocket WebFacing Primer: List Price, $39
    Migrating to WebSphere Express for iSeries: List Price, $49
    Getting Started with WebSphere Express for iSeries: List Price, $49
    The All-Everything Operating System: List Price, $35
    The Best Joomla! Tutorial Ever!: List Price, $19.95

    No Truncate Table? No Problem! Security of SecurID In Question Following Hack of RSA

    Leave a ReplyCancel reply

Volume 11, Number 11 -- March 23, 2011
THIS ISSUE SPONSORED BY:

Bytware
ProData Computer Services
Twin Data Corporation

Table of Contents

  • Taking RSE to Task
  • Today’s Horoscope
  • Admin Alert: Must Your Rack Be IBM Black?
  • Duplicating an Entire Table or a Subset of a Table Using SQL
  • No Truncate Table? No Problem!
  • Automatically Deleting Spooled Files through Expiration Dates

Content archive

  • The Four Hundred
  • Four Hundred Stuff
  • Four Hundred Guru

Recent Posts

  • PHP’s Evolution On The IBM i Platform Continues
  • Protecting IBM i Data For The AI Revolution
  • Guru: Two More Small But Handy RPG Enhancements: LIKE(*EXT) And %LOOKUPNE
  • IBM i Integration Gives Costco Shoppers Real-Time Inventory
  • IBM i PTF Guide, Volume 28, Number 33
  • IBM “Price Harmonization” Increases For Power Systems Coming In The New Year
  • Code For i Continues To Grow. Here Is What’s New
  • PowerSC: Your One-Stop Shop For Security On IBM i – And Beyond
  • As I See It: You’ve Been Flocked
  • IBM i PTF Guide, Volume 28, Number 32

Subscribe

To get news from IT Jungle sent to your inbox every week, subscribe to our newsletter.

Pages

  • About Us
  • Contact
  • Contributors
  • Four Hundred Monitor
  • IBM i PTF Guide
  • Media Kit
  • Subscribe

Search

Copyright © 2025 IT Jungle