In CUPS 1.2+ (shipped with RHEL/CentOS 5 and later), the default ErrorPolicy
changed from retry-job
to stop-printer
. This means when printers encounter errors like:
- USB disconnection
- Network timeouts
- Paper jams
- Out of toner/ink
The printer automatically gets disabled instead of retrying the job. This creates administrative overhead in multiuser environments where printers need to be manually re-enabled with cupsenable
.
For existing printers, you can modify the error policy either through:
# Command line method
lpadmin -p printer_name -o printer-error-policy=retry-job
# Direct config edit (requires cups restart)
sed -i 's/ErrorPolicy stop-printer/ErrorPolicy retry-job/' /etc/cups/printers.conf
service cups restart
To make retry-job
the global default for all newly added printers:
# Edit cupsd.conf
vi /etc/cups/cupsd.conf
# Add this directive (create if doesn't exist)
DefaultErrorPolicy retry-job
# Restart CUPS
service cups restart
For older CUPS versions (pre-1.4), you might need to modify the printer templates:
# RHEL/CentOS 5 location
vi /etc/cups/ppd-standard.tmpl
# Find and replace
s/DefaultErrorPolicy stop-printer/DefaultErrorPolicy retry-job/
After making changes, verify with:
# Check default policy
lpoptions -l | grep ErrorPolicy
# Test printer status
lpstat -p -d
# Force an error (replace with your printer URI)
usb_printer_uri="$(lpstat -v | awk '{print $3}' | sed 's/://')"
cupsdisable "$usb_printer_uri" && sleep 30 && cupsenable "$usb_printer_uri"
For managing multiple servers, create a deployment script:
#!/bin/bash
# Set default error policy for all CUPS servers
CONF_FILE="/etc/cups/cupsd.conf"
TEMP_FILE="/tmp/cupsd.tmp"
# Backup original config
cp "$CONF_FILE" "${CONF_FILE}.bak-$(date +%F)"
# Process config file
awk '
/DefaultErrorPolicy/ {
sub(/stop-printer/, "retry-job")
found=1
}
{ print }
END {
if (!found) print "DefaultErrorPolicy retry-job"
}' "$CONF_FILE" > "$TEMP_FILE"
# Replace config
mv "$TEMP_FILE" "$CONF_FILE"
# Apply to existing printers
for printer in $(lpstat -v | awk '{print $3}' | sed 's/://'); do
lpadmin -p "$printer" -o printer-error-policy=retry-job
done
# Restart CUPS
service cups restart
Since RHEL/CentOS 5, CUPS has defaulted to using stop-printer
as its error policy when printers encounter issues like:
- USB disconnections
- Network timeouts
- Paper jams
- Out-of-toner situations
This means any temporary failure automatically disables the printer until someone manually runs cupsenable
. In multi-user environments, this creates unnecessary administrative overhead.
The default behavior is defined in each printer's configuration in /etc/cups/printers.conf
:
<Printer example>
...
ErrorPolicy stop-printer
</Printer>
While we can override this during printer creation:
lpadmin -p printer_name -v device_uri -o printer-error-policy=retry-job -E
or by manually editing the config file, these are temporary solutions that don't address the root issue.
To make retry-job
the system-wide default, modify CUPS' main configuration:
# Edit the cupsd.conf file
sudo vim /etc/cups/cupsd.conf
# Add this line in the main section:
DefaultErrorPolicy retry-job
# Restart CUPS
sudo service cups restart
After making this change, verify it works:
# Create a test printer
sudo lpadmin -p testprinter -v file:/dev/null -E
# Check its error policy
lpoptions -p testprinter | grep ErrorPolicy
# Expected output:
printer-error-policy=retry-job
For printers already configured, use this bash script to update them all:
#!/bin/bash
for printer in $(lpstat -v | awk '{print $3}' | tr -d ':')
do
sudo lpadmin -p $printer -o printer-error-policy=retry-job
echo "Updated $printer to retry-job policy"
done
For large deployments, consider implementing this through configuration management:
Ansible playbook example:
- name: Configure CUPS error policy
hosts: printservers
tasks:
- name: Set default error policy
lineinfile:
path: /etc/cups/cupsd.conf
line: "DefaultErrorPolicy retry-job"
state: present
notify: restart cups
- name: Update existing printers
command: lpadmin -p {{ item }} -o printer-error-policy=retry-job
loop: "{{ ansible_facts.cups_printers }}"
handlers:
- name: restart cups
service:
name: cups
state: restarted
Puppet manifest example:
class cups_config {
file_line { 'cups_error_policy':
path => '/etc/cups/cupsd.conf',
line => 'DefaultErrorPolicy retry-job',
match => '^DefaultErrorPolicy',
}
exec { 'update_printers':
command => 'lpstat -v | awk \'{print $3}\' | tr -d \':\' | xargs -I {} lpadmin -p {} -o printer-error-policy=retry-job',
path => ['/usr/bin', '/usr/sbin'],
refreshonly => true,
subscribe => File_line['cups_error_policy'],
}
}
If changes don't take effect:
- Verify CUPS version supports
DefaultErrorPolicy
(1.2+) - Check for syntax errors in cupsd.conf
- Ensure no printer-specific overrides exist
- Verify SELinux context if issues persist