Automating CUPS with shell commands
Status Information
The lpstat
command outputs status information about printers, print jobs, and CUPS services (Figure 3). For example, lpstat -r
finds out whether the daemon is running. The switch -d
identifies the default printer. For a summary of the default printer, the device URI, and its status, use lpstat -t
. You can find all the commands available from the man page (man lpstat
).
The lpc
command provides limited control over printer queues; lpc status
lists all available printers. Entering
lpc status | grep : | tr -d \:
reduces the output to just the printer name. To limit the output to a single device, type lpc status <printer>
. If lpc
is called without any parameters, you land in a command interpreter, which unlike the original from the BSD world, does not offer much functionality.
Administering CUPS
Two command-line tools, cupsdisable
and cupsenable
, let you control the print queue. Table 4 lists essential commands for cupsenable
and cupsdisable
(Figure 4).
Table 4
Controlling the Queue
Command | Result |
---|---|
cupsenable <printer> |
Start print queue |
cupsdisable <printer> |
Stop print queue |
cupsdisable -r "<reason>" <Printer> or cupsreject -r "<reason>" <Printer> |
Stop print queue with message <reason> |
cupsaccept <printer> |
Accept print jobs |
cupsreject <printer> |
Reject print jobs |
Using cupsdisable
, you can stop a print queue and deactivate the device (e.g., when the device location is changed or repairs are needed). However, you should always inform users about the stoppage. All print jobs are saved when the queue is deactivated, and they can then be resumed with cupsenable
. If, instead, you decide to interrupt all print jobs, the print queue should be stopped with cupsdisable -c
.
To prevent unnecessary costs associated with the use of specialty printers, such as imagesetters, label printers, and color laser printers, you can refuse to accept (cupsreject
) or temporarily permit (cupsaccept
) print jobs (Figure 4). CUPS outputs accepted print jobs completely, even if you reject new jobs while the current job is being processed; however, this is not the case when you use cupsenable
and cupsdisable
to start and stop print queues.
« Previous 1 2 3 4 Next »
Buy this article as PDF
Pages: 6
(incl. VAT)