Clearing a Print Queue Backlog in AIX

By | February 13, 2015

We have a z/OS application that streams data down to our AIX-based POWER7 server. On the server, we have a SAS application that turns the stream into a PDF document and sends the PDF to a printer which is specified by the user on the z/OS application. Many of the printers that are assigned to the z/OS application have been decommissioned, yet the end users continue to send print jobs to them. This dynamic requires us to do quarterly housekeeping on the z/OS and AIX environments to keep active printers current.

During the quarter, however, end users will inadvertently send print jobs to printers that don’t exist anymore, so the AIX server creates a backlog of orphaned print jobs over time. Below are the steps to clean up the backlog. I originally found these steps on IBM’s web site.

You must be logged in as root or as a user with sudo access.

  1. If possible, let all current print jobs finish printing or cancel them. To cancel a print job, issue the lpstat command to get the print job number, then use the enq command to cancel the print job.

    enq -x JobNumber

    The lpstat command displays information about the current status of the line printer. The enq command enqueues a file.

  2. Issue the following command to stop qdaemon:

    stopsrc -s qdaemon

  3. Issue the following commands to verify that qdaemon did not fork other processes:

    ps -ef | grep qdaemon
    ps -ef | grep pio

    The ps command shows the current status of processes. The grep command searches a file for a pattern. If you get one line back from each of the above grep commands, skip step 4 and go to step 5. If you get more than one line, go to step 5.

  4. If other qdaemons or pios were returned by the ps -ef command, kill these processes by issuing the following command with each process ID:

    kill -9 pid

    The following example shows a qdaemon returned by ps -ef. The process ID is 3357.

    root 3357 2288 0 13:32:21 - 0:04 dtterm

    To kill this process ID, enter kill -9 3357 at the command line.

  5. Change the directory as follows:

    cd /var/spool/lpd/qdir

  6. Issue a pwd command to verify that you are in the proper directory. Then, remove all files in this directory using the rm command:

    rm *

    The pwd command writes to standard output the full path name of your current directory (from the root directory). The rm command removes the entries for the specified file or files from a directory.

  7. Change the directory again:

    cd /var/spool/lpd/stat

  8. Issue a pwd command to verify that you are in the proper directory. Then, remove all files in this directory:

    rm *

  9. Change the directory again:

    cd /var/spool/qdaemon

  10. Issue a pwd command to verify that you are in the proper directory. Then, remove all files in this directory:

    rm *

  11. Follow this step if you are having trouble with the remote queue or lpd. Change the directory:

    cd /var/spool/lpd

  12. Issue a pwd to verify that you are in the proper directory. Then, remove all files in this directory using the rm command:

    rm *

    Note: The rm command will not remove the subdirectories.

  13. Start qdaemon:

    startsrc -s qdaemon

Leave a Reply

Your email address will not be published. Required fields are marked *