Generally speaking, a spooler is a queue for a limited resource. It is a way of throttling and controlling access to these resources. In the long-forgotten dark days of yore, computers were extremely expensive. They were held in big rooms and operated by nice men in sparkling white coats. The peripherals were also expensive. Access to things such as printing, communications, and so on needed to be rationed and controlled. One way to do this is via spooling. Spooling uses a queue to buffer requests for a physical resource. This allows multiple users to leverage use of this scarce physical resource. Spooling also enables devices that communicate at different rates to exchange data (buffering). A spooler allowed for not only job queuing but also prioritization. A spooler also allows for the service to be run by a privileged user and enables queued jobs to run after a user has submitted a request but is no longer accessing the system. A good example of spooling is the line at the bank. There is a finite number of tellers, and the customers must wait for their turn in a queue. This is an efficient and equitable way to enable access to the scarce resource of tellers. In this chapter, we discuss troubleshooting the print spoolers used under Linux. The three major spooler types are
The concepts could be applied to other print spoolers as well. We discuss the LPRng (a modified Berkeley-style spooler) and CUPS spoolers in depth. LPRng is a rewrite and extension of the original Berkeley spooler. It also enables System V commands to control the spooler. CUPS (Common UNIX Printing System) is a new type of spooler. It was designed to work across most UNIX- and Linux-based systems. It is also standards based. It enables printing through RFC1179 (lpr), IPP, CIFS/SMB, Raw socket (JetDirect), and through local printing. CUPS uses network printer browsing and PostScript Printer Description (PPD) files to ease the common tasks of printing. You can determine which spooler you have by querying your operating system. On RPM-based systems, run rpm -qa | grep -i "cups\|lp". This command should return either CUPS or LPRng RPMs. If it returns both, you must confirm which is running (with ps). You can also use chkconfig to confirm which of the two is started on system reboot. On a Debian-based system, you must use dpkg -l to verify which spooler is installed. Spoolers can be managed through graphical interfaces or from the command line. Generally, the GUI is easier for day-to-day usage, but for troubleshooting, it is best to know how to use the command-line interfaces. We explore them in depth in this chapter. Print spoolers generally consist of a daemon, spool directories, and a series of configuration files. The daemon accepts the print requests, spools them, monitors the queues, enables changes to print order, cancels print requests, monitors the hardware, formats the print requests, and transfers them to the print device. The spool directories hold the files to be printed until they are formatted and transferred. The configuration files hold the general spooler configuration, printer-specific data, transfer scripts, and so on. The jobs can be sent unformatted (raw) or formatted (cooked). The formatting is generally performed by a Page Description Language (PDL) such as PCL or PostScript. In some instances, a print queue might not actually be connected to an output device. For example, a print queue can be used to output a PDF file instead of printed paper. Using the Spooler Commandslp is the standard command used by System V-style spoolers to submit print requests. CUPS and LPRng also support lp tHRough emulation. Table 11-1 lists the tasks you can accomplish with various lp commands.
lpr is the standard command used by BSD-style spoolers to submit print requests. CUPS supports lpr through emulation, and LPRng supports it natively. Table 11-2 lists lpr uses and commands.
lpadmin is the standard command used by System V-style spoolers to configure printers and classes. It is used in CUPS and System V spoolers. There is no BSD equivalent of lpadmin. With BSD spoolers, you just manually edit the /etc/printcap file. Table 11-3 lists lpadmin uses and commands.
lpstat is the standard command used by System V-style spoolers to query the status of the spooler, print queues, and jobs. $ lpstat -t scheduler is running system default destination: dj5 device for dj5: usb://hp/deskjet%205550 device for Laser: ipp://localhost/ipp dj5 accepting requests since Jan 01 00:00 Laser accepting requests since Jan 01 00:00 printer dj5 disabled since Jan 01 00:00 - Unable to open USB device "usb://hp/deskjet%205550": No such device printer Laser is idle. enabled since Jan 01 00:00 dj5-1 jtk10 11724800 Fri 21 Jan 2005 10:12:22 PM EST lpq is the standard command used by BSD-style spoolers to query the status of the spooler, print queues, and jobs. $ lpq dj5 is not ready Rank Owner Job File(s) Total Size 1st jtk10 1 (stdin) 11724800 bytes lpoptions is the CUPS command to display or set printer options and defaults. This command is only available in CUPS. For example, you could create two queues for a printer and use lpoptions to set the second queue to print in landscape mode by default. $ lpoptions job-sheets=none,none cpi=12 lpi=7 page-bottom=86 page-left=57 page-right=57 \ page-top=72 scaling=100 wrap=true $ lpoptions -o scaling=150 [jtk10@sanctus ~]$ lpoptions job-sheets=none,none cpi=12 lpi=7 page-bottom=86 page-left=57 page-right=57 \ page-top=72 scaling=150 wrap=true The options for the print queues are saved in the following locations (from the man page): ~/.lpoptions - user defaults and instances created by non-root users. /etc/cups/lpoptions - system-wide defaults and instances created by the root user. Spooler PlumbingThink of the spooler as the plumbing in your house and the capability to turn taps on or off as the capability to control job flow to the queues (see Figure 11-1). A main spooler function is the capability to control the flow of jobs through it. It is important to be able to do the following:
Figure 11-1. A simple example that shows the "plumbing" of a System V-style print spooler
The commands used to control the job flow plumbing are:
usage: lpc [-Ddebuglevel][-Pprinter][-Shost][-Uusername][-V] [command] with no command, reads from stdin -Ddebuglevel - debug level -Pprinter - printer or printer@host -Shost - connect to lpd server on host -Uuser - identify command as coming from user -V - increase information verbosity commands: active (printer[@host]) - check for active server abort (printer[@host] | all) - stop server class printer[@host] (class | off) - show/set class printing disable (printer[@host] | all) - disable queueing debug (printer[@host] | all) debugparms - set debug level for printer down (printer[@host] | all) - disable printing and queueing enable (printer[@host] | all) - enable queueing hold (printer[@host] | all) (name[@host] | job | all)* - hold job holdall (printer[@host] | all) - hold all jobs on kill (printer[@host] | all) - stop and restart server lpd (printer[@host]) - get LPD PID lpq (printer[@host] | all) (name[@host] | job | all)* - run lpq lprm (printer[@host] | all) (name[@host]|host|job| all)* - run lprm msg printer message text- set status message move printer (user|jobid)* target - move jobs to new queue noholdall (printer[@host] | all)- hold all jobs off printcap(printer[@host] | all) - report printcap values quit - exit LPC redirect(printer[@host] | all) (printer@host | off )* - redirect jobs redo (printer[@host] | all) (name[@host] | job | all)* - redo jobs release (printer[@host] | all) (name[@host] | job | all)* - release jobs reread (printer[@host]) - LPD reread database information start (printer[@host] | all) - start printing status (printer[@host] | all) - status of printers stop (printer[@host] | all) - stop printing topq (printer[@host] | all) (name[@host] | job | all)* - reorder job up (printer[@host] | all) - enable printing and queueing diagnostic: defaultq - show default queue for LPD server defaults - show default configuration values client (printer | all) - client config and printcap information server (printer | all) - server config and printcap
$ lpq dj5 is ready and printing Rank Owner Job File(s) Total Size 1st jtk10 3 hosts 1024 bytes 2nd jtk10 4 hosts 1024 bytes [jtk10@sanctus ~]$ lprm 3 [jtk10@sanctus ~]$ lpq dj5 is ready and printing Rank Owner Job File(s) Total Size 1st jtk10 4 hosts 1024 bytes
One key concept is the difference between spooling requests and printing them. The reject command enables you to stop jobs from printing and spooling. If a user tries to print to a queue that is set to reject, the following occurs: $ reject dj5 $ lpstat -p printer dj5 disabled since Jan 01 00:00 - Rejecting Jobs $ lp -d dj5 /etc/hosts lp: unable to print file: server-error-not-accepting-jobs $ accept dj5 The disable command stops jobs from printing, but they still spool up in the queue. $ accept dj5 $ disable dj5 $ lpstat -p printer dj5 disabled since Jan 01 00:00 - Paused $ lp -d dj5 /etc/hosts request id is dj5-2 (1 file(s)) $ lpstat -t scheduler is running system default destination: dj5 device for dj5: usb://hp/deskjet%205550 device for Laser: ipp://localhost/ipp dj5 accepting requests since Jan 01 00:00 Laser accepting requests since Jan 01 00:00 printer dj5 disabled since Jan 01 00:00 - Paused printer Laser is idle. enabled since Jan 01 00:00 dj5-2 jtk10 1024 Sat 29 Jan 2005 11:31:05 AM EST $ enable dj5 After the print queue is enabled, the print requests begin printing on the printer. Term DefinitionsIt is important to further clarify spooling and printing terms. They are very specific, and using them incorrectly can lead to creating, fixing, or deleting the wrong resource. Let's take time out for a second and make sure we understand the terminology.
|