How to discard a printing job to a network CUPS printer when it's not available (turned off).

Solution Verified - Updated -

Environment

Red Hat Enterprise Linux
CUPS

Issue

CUPS needs to be configured to discard a printing job if a network printer is not accessible (turned off for example).

Resolution

No resolution exists at the time of writing.

One workaround is to use CUPS classes + Backend Error Handler backend, please refer to the following URLs for furhter info:

CUPS Documentation - Classes Reference
Backend Error Handler download page

The main idea is that when socket:// backend is called from a class, it won't wait for a particular printer to come online, after some delay it will exit with an error trying to pass the job to the next printer in a class.
What could be done is to:

  • create a class which will contain only one printer
  • set this printer DeviceURI to beh:/1/2/120/socket://[printer IP]:9100/
  • send print jobs to a class instead of printer directly

Example configuration could look like this:

  • /etc/cups/classes.conf
<Class test_class>
  Info test_class
  Location virtual_box
  State Idle
  StateTime 1353332773
  Accepting Yes
  Shared Yes
  JobSheets none none
  Printer PrinterOne # only one printer per class
  QuotaPeriod 0
  PageLimit 0
  KLimit 0
  OpPolicy uktest
  ErrorPolicy retry-job
</Class>
  • /etc/cups/printer.conf
<Printer PrinterOne>
  Info PrinterOne
  Location 
  DeviceURI beh:/1/3/10/socket://<printer IP address>:9100/
  State Idle
  StateTime 1353333177
  Accepting Yes
  Shared Yes
  JobSheets none none
  QuotaPeriod 0
  PageLimit 0
  KLimit 0
  OpPolicy policy1
  ErrorPolicy retry-job
</Printer>

Root Cause

Basically CUPS is missing the needed functionality, when printer is not responding over network - CUPS consider this is fine and just tries to reach the printer again and again.
By this design, socket:// printing backend will loop the job infinitive in case it gets no reply from a printer.
There's a closed bug on the CUPS site where developers told that they wont fix that:

Diagnostic Steps

  • /etc/cups/cupsd.conf file has following settings:
JobRetryInterval 3m
JobRetryLimit 3 

But this is not working as expected - instead of deleting the job after specified Retry Interval & Limit CUPS keeps trying to print every 30 seconds.
Following messages are found in the /var/log/cups/error_log:

Error message: recoverable: Unable to connect to printer; will retry in 30 seconds...

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

Close

Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.