Problem:
I noticed this strange problem on an RHEL 4 server which has a
vanilla CUPS setup. Once in a while, I come to work and lots of
users are already mad at me because the queues are long, nothing
is printing, and lpq says "printer not ready". I power-cycle the
printer, start /usr/bin/enable, and everything works again.
It seems like CUPS shuts down printing on a queue when one of the
file encounters a problem (which is very common with our older
HP4000 printers). When we used LPRng, it would keep sending a
file 3 times, and then give up. When this happened, users could
power-cycle the printer to bring it back to life and then send
the job again.
Half-Assed Solution:
In the end I took a more brute force approach. I added a simple, one
line script to cron which checks for disabled printers every two minutes
and enables any that it finds. It's crude, but actually quite
effective. Credit for the script goes to someone on the CUPS forum.
/usr/sbin/lpc status | grep -B4 "printing is disabled" | grep : | tr -d ":" | xargs --max-args=1 /usr/bin/enable
Three-Quarters-Assed Solution:
- checks for cupsd running and tries to restart it if it isn't
- logs and bails if the restart attempt fails
- logs the printers to be "enable"d
#!/bin/bashCUPSPID=`pgrep cupsd`
if [ -z "$CUPSPID" ] ; then
service cups restart 2>&1 > /dev/null
CUPSPID=`pgrep cupsd`
if [ -z "$CUPSPID" ] ; then
logger -t cups-watch failed to restart CUPS
exit 1
fi
fi
/usr/sbin/lpc status | grep -B4 "printing is disabled" | grep : | tr -d ":" | xargs --max-args=1 logger -t cups-watch enable
/usr/sbin/lpc status | grep -B4 "printing is disabled" | grep : | tr -d ":" | xargs --max-args=1 /usr/bin/enable