Take the 2-minute tour ×

I have printer in CUPS that due to driver problems (HP 1010) from time to time goes into pause.

I would like to write a shell script that will execute once per hour to resume a printer in CUPS. But I have no idea after googling for couple of minutes how to resume printer from shell command line.

share|improve this question

migrated from stackoverflow.com May 7 '11 at 11:23

This question came from our site for professional and enthusiast programmers.

Aren't you accepting any of the answers you got? –  Kurt Pfeifle Jun 24 '10 at 17:51
add comment

8 Answers

The -E option of lpadmin should do that. You can probably just create a cron job with the lpadmin command.

lpadmin [ -E ] [-U username ] [ -h server[:port] ] -p printer option(s)

Hourly cron entry:

0 * * * * /usr/sbin/lpadmin -E -p your_printer

You can add that by running:

sudo crontab -e
share|improve this answer
This is wrong. -E in this context is a printer option, and must go AFTER the printer name, otherwise you are just turning on communication encryption. developer.apple.com/library/mac/documentation/Darwin/Reference/… -- When specified before the -d, -p, or -x options, the -E option forces encryption when connecting to the server. –  scragar Apr 28 at 17:23
add comment

There's the cupsenable command.

cupsenable printer

starts a disabled printer (to find out the printername you can list your printers with lpstat -p or lpc status).

You may have to run the command as root or through sudo. So if you have to enable the printer in a shell script, you would have to add the shell to root's crontab, or edit your sudoers file.

share|improve this answer
add comment

As others have already said, 'cupsenable' or 'lpadmin -E' should do the trick.

A related issue is IIRC that by default CUPS configures the printer such that if printing a job fails somehow, the printer is disabled. You can change this to abort the job instead.

share|improve this answer
add comment

Your problem could be tackled in different ways, depending on the version of CUPS you're running.

More recent versions of CUPS (version 1.2 and above) come with a builtin functionality that could help here. It's called "ErrorPolicy". It's default setting is selected in cupsd.conf, and determines how cupsd should handle print queues which do not behave as expected. You have 3 choices to tag to each queue individually:

ErrorPolicy abort-job  
ErrorPolicy retry-job  
ErrorPolicy retry-this-job  
ErrorPolicy stop-printer  
-- Abort this job and proceed with next job in same queue
-- Retry this job after waiting for N seconds (where N is determined by cupsd.conf's "JobRetryInterval" directive).
-- Retry current job immediately and indefinitely.
-- Stop current print queue and keep the job for future printing. This is still the default, unless you define otherwise as per above mentioned alternatives It also was default + only possible behaviour for all queues in previous versions of CUPS (the one you do want to get rid of as per your question).

Additionally, you can set individual ErrorPolicies to each separate print queue. This setting would be noted in the printers.conf file. (Set it from a commandline with lpadmin -p printername -o printer-error-policy=retry-this-job).

For older versions of CUPS I'd recommend to have a look at beh, the CUPS BackEnd Handler. beh is a wrapper which can be applied to any CUPS backend.

Assuming your print queue currently has defined a backend of socket://, and it behaves in the way you don't like (being disabled by cupsd from time to time due to network connection problems). With beh you'd re-define your backend like this:


This would retry a job 20 times in two minute intervals, and disable the queue only when still not succeeding. Or you could do this:


This retries the job 3 times with 5 second delays between the attempts. If the job still fails, it is discarded, but the queue is not disabled. You want to let cupsd try indefinitely to connect to the device? Good, try this:


Try infinitely until printer comes back. Intervals between connection attempts are 30 seconds. The job does not get lost when the printer is turned off. You can intentionally delay printing simply by switching off the printer. A good configuration for desktop printers and/or home users.

Overall, there is no need to mess around with bash scripts, cron jobs, lpadmin, cupsenable or sudo in order to re-activate CUPS queues going down erratically.

share|improve this answer
add comment

I updated cupsd.conf with the line:

ErrorPolicy abort-job

Then I restarted cupsd using: /etc/init.d/cups restart

But when I look at the printers.conf file, the ErrorPolicy is not updated. According to the cups documentation, line "ErrorPolicy abort-job" must appear in the printer section.

I also tried with lpadmin to update the ErrorPolicy. Nothing changes the ErrorPolicy or it does not make it to the printers.conf file.

What am I missing? How do I make sure that cupsd actually aborts a job on error?

share|improve this answer
edit printers.conf –  Saurabh Jun 29 at 4:19
add comment

lpadmin -p p-go-avtom2 -v p-go-avtom2 -E


share|improve this answer
Care to explain what this does, exactly? Please add a little more context. –  slhck Jul 15 '12 at 21:50
add comment

My printer is HP CP1215 had also an error: Printer Paused - "/usr/lib/cups/backend/hp failed"

After restarting both cups and avahi-daemon and identifying printer with lpstat -p and enabling with cupsenable, I was able to print again. Restarting only cups and enabling did not do the trick.

I also changed default policy to retry-job and finally ended up avoiding errors in future with cronjob:

* * * * * lpstat -p |grep "poissa käytöstä" && service avahi-daemon restart; service cups restart; cupsenable HP_Tuloostin

where poissa käytöstä is Finnish localization text for maintenance "out of order" and HP_Tuloostin is name of my printer.

In my experience both default-policy and current printer policies should be configured to be retry-job. Default policy is just policy which you get when you are installing a new printer.

share|improve this answer
add comment
ls /etc/cups/ppd/ |cut -d "." -f1 |grep -v VMware |xargs -i cupsenable {}

This lists all ppd files which represent an installed printer, cuts off the ppd extension, ignores a VMware ppd included on a lot of VMware servers (if you don't need this just remove |grep -v VMware), and passes the other names to xargs which unpauses all of the printers.

A cron job should make this work well.

share|improve this answer
add comment

protected by ÃŁŁǫǛȉЖΦΤїҪ Jan 27 at 19:49


Would you like to answer one of these unanswered questions instead?
