Meniu

cups — fixing cups printer problem: lpd failed

Recently, our HP2420dn printer stopped working. Well, it was not really the printer… printing jobs went but nothing came out of the printer. The cups server has put the printer into a stopped state with the StateMessage /usr/lib/cups/backend/lpd failed.

What caused this? Well, I am not really sure, however the cups server error logs (http://localhost:631/admin/log/error_log, or alternatively /var/log/cups/error_log) tell at least part of the story, as shown below.

...
I [22/Sep/2007:12:36:40] Adding start banner page "none" to job 835.
I [22/Sep/2007:12:36:40] Adding end banner page "none" to job 835.
I [22/Sep/2007:12:36:40] Job 835 queued on "printer" by "kamil".
I [22/Sep/2007:12:36:40] Started filter /usr/lib/cups/filter/pstops (PID 2607) for job 835.
I [22/Sep/2007:12:36:40] Started backend /usr/lib/cups/backend/lpd (PID 2608) for job 835.
I [22/Sep/2007:12:37:53] Adding start banner page "none" to job 836.
I [22/Sep/2007:12:37:53] Adding end banner page "none" to job 836.
I [22/Sep/2007:12:37:53] Job 836 queued on "printer" by "kamil".
...
W [22/Sep/2007:12:41:41] [Job 835] Remote host did not respond with command status byte after
300 seconds!
E [22/Sep/2007:12:41:45] PID 2608 (/usr/lib/cups/backend/lpd) stopped with status 1!
I [22/Sep/2007:12:41:45] Hint: Try setting the LogLevel to "debug" to find out more.
I [22/Sep/2007:12:41:45] [Job 835] Backend returned status 1 (failed)
I [22/Sep/2007:12:41:45] Saving printers.conf…
…

From the above error log fragments, it can be seen that the communication with the HP printer timed out, causing the lpd to exit with an error status. Now, because of this error, the cups server has stopped the printer. Later on I'll show you how to alter this default cups behaviour. Now, lets take a quick look at the printer queue status using the following command.

lpq

The printer is listed as not ready as is shown in the output below.

printer is not ready
no entries

Interestingly, this error happend on a few workstations around the same time. Anyhow, there are number of ways to fix such a problem. One could remove the printer and then install it again. That fixes it, but there are simpler ways. One could use some sort of front end to cups configuration, such as its web interface (i.e. http://localhost:631/), to start the printer again. Or, one could edit cups config files directly, solution courtesy of Mr Brett Wildermoth. This is how I got our printer working again.

Fixing the problem
First, to verify that you are experiencing the same kind of problem as I did, run:

sudo cat /etc/cups/printers.conf # ©2007 dsplabs.com.au

This should show you a list of installed printers with their settings and status, as show below.

# Printer configuration file for CUPS v1.2.10
# Written by cupsd on 2007-09-22 12:41
Info HP2420dn
Location SPL
DeviceURI lpd://123.234.103.10/printer
State Stopped
StateMessage /usr/lib/cups/backend/lpd failed
StateTime 1190428905
Accepting Yes
Shared Yes
JobSheets none none
QuotaPeriod 0
PageLimit 0
KLimit 0
OpPolicy default
ErrorPolicy stop-printer
Info richo afico 3030
Location outside spl
DeviceURI socket://123.234.102.11:9100
State Idle
StateTime 1183439409
Accepting Yes
Shared Yes
JobSheets none none
QuotaPeriod 0
PageLimit 0
KLimit 0
OpPolicy default
ErrorPolicy stop-printer

The above config file shows that there are two printers installed under cups with the following device URIs lpd://123.234.103.10/printer and socket://123.234.102.11:9100. The first printer (HP2420dn) is in a stopped state due to a lpd error. To fix the problem you'll have to replace the follwing two lines in the /etc/cups/printers.conf file:

State Stopped
StateMessage /usr/lib/cups/backend/lpd failed

with this line:

State Idle

To achieve the above you could use your favourite text editor, or the following sed on-liner.

sudo sed -i -e '/StateMessage .*lpd failed/d' -e 's/State Stopped/State Idle/' /etc/cups/printers.conf

Have another look at the output of:

sudo cat /etc/cups/printers.conf # ©2007 dsplabs.com.au

to double check that fixing the error lines worked correctly. My /etc/cups/printers.conf file now look as follows.

# Printer configuration file for CUPS v1.2.10
# Written by cupsd on 2007-09-22 12:43
Info HP2420dn
Location SPL
DeviceURI lpd://123.234.103.10/printer
State Idle
StateTime 1190428905
Accepting Yes
Shared Yes
JobSheets none none
QuotaPeriod 0
PageLimit 0
KLimit 0
OpPolicy default
ErrorPolicy stop-printer
Info richo afico 3030
Location outside spl
DeviceURI socket://123.234.102.11:9100
State Idle
StateTime 1183439409
Accepting Yes
Shared Yes
JobSheets none none
QuotaPeriod 0
PageLimit 0
KLimit 0
OpPolicy default
ErrorPolicy stop-printer

Then the final step is to restart the cups server using:

service cups restart

or alternatively:

/etc/init.d/cups restart

Note that on your platform cups daemon might actually be called cupsd. If so, you'll have to change the above commands accordingly to reflect this difference. Now, looking at the printer queue status once more (using the lpq command) we see that the problem is fixed.

printer is ready
no entries

You may have noticed that there is an entry in the /etc/cups/printers.conf file called ErrorPolicy set to stop-printer. This could be changed so that the printer does not get stopped on an error. The other possible settings are abort-job and retry-job. You could use the following sed one-liner for this purpose.

sudo sed -i -e 's/ErrorPolicy stop-printer/ErrorPolicy abort-job/' /etc/cups/printers.conf

Hope this helps!

Mirela

Zona de mobile
  • | 34 articole

Nici un comentariu inca. Fii primul!
  • powered by Verysign