What Is a Spooler?


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 System V-style spooler

  • The Berkeley-style spooler

  • CUPS-based spoolers

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 Commands

lp 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.

Table 11-1. Various Printing Needs and the Corresponding lp Commands

Printing Need

Command

Submit a print request to the default printer

lp/etc/hosts

Submit a print request to a specific printer

lp -d printera/etc/hosts

Submit two copies of a print request

lp -n 2 /etc/hosts

Submit a print request to print landscape

lp -o landscape/etc/hosts

Send mail after printing

lp -m /etc/hosts

Omit printing the banner page

lp -o nb /etc/hosts

Print a banner page

lp -o yb/etc/hosts

Print two pages side by side on the paper

lp -o 2up /etc/hosts

Print on both sides of the paper

lp -o duplex /etc/hosts

Print raw output to the printer

lp -o raw /home/user/afile.pcl

Print request from paper tray 2

lp -o tray2/etc/hosts


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.

Table 11-2. Various Printing Needs and the Corresponding lpr Commands

Printing Need

Command

Submit a print request to the default printer

lpr /etc/hosts

Submit a print request to a specific printer

lpr p printqueue /etc/hosts

Submit two copies of a print request

lpr -# 2 /etc/hosts

Submit a print request to print landscape

lpr Zlandscape /etc/hosts

Send mail after printing

lpr m /etc/hosts

Omit printing the banner page

lpr h /etc/hosts

Print two pages side by side on the paper

lpr Z2up /etc/hosts

Print on both sides of the paper

lpr Zduplex /etc/hosts

Print raw output to the printer

lpr Ztype=raw /home/user/afile.pcl

Print request from paper tray 2

lpr Ztray=2/etc/hosts


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.

Table 11-3. Various Printing Needs and the Corresponding lpadmin Commands

Printing Need

Command

Change the system default printer

lpadmin d printqueue

Remove a print queue

lpadmin -xprintqueue


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 Plumbing

Think 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:

  • Move a job to another device

  • Reject or accept requests from queuing or printing

  • Cancel queued requests

  • Disable or enable requests to print but still allow them to queue

  • Redirect new print requests to another device

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:

  • lpc The BSD spooler command that encompasses the functionality of accept, reject, disable, enable, lpmove, and also some functionality of lpstat. CUPS implements a limited subset of this command.

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


  • lprm The standard command used by BSD-style spoolers to cancel print requests.

$ 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


  • cancel The standard command used by System V-style spoolers to remove pending print requests.

  • accept The standard command used by System V-style spoolers to tell a print queue to begin spooling print requests.

  • reject The standard command used by System V-style spoolers to stop spooling print requests.

  • disable The standard command used by System V-style spoolers to stop printing print requests.

  • enable The standard command used by System V-style spoolers to begin printing print requests.

  • lpmove The standard command used by System V-style spoolers to move a print request from one print queue to another.

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 Definitions

It 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.

  • Queue A queue is a fancy name for a line. It is the line in which requests wait for a particular resource. A queue can be attached to a printer, a class, or other devices.

  • Class A class is grouping of print queues based on the function of the printers in the class. This grouping could be based on job function (for example, accounting department printers), location, device type (for example, all laser printers), or other classifications.

  • Job A job is another name for a request for a service. It is the smallest unit into which you can break a request.

  • User disassociation Because requests are queued where they can be controlled and printed by the daemon, you can perform other operations on the computer while the printing takes place in the background. By passing the job through a daemon, you can disassociate it from the specific user. The job becomes owned by the daemon's user instead of the user who submitted it. Usually the submitting user is noted in some control file or log. For example, this process can be performed by passing the request files through a named pipe. The daemon picks up the files on the other side and processes them.

  • Abstraction There are many (sometimes conflicting) definitions of abstraction. It is a programming technique that hides complexity. The best example is the VFS portion of the Linux kernel. VFS is a virtual filesystem layer that sits on top of the filesystem drivers. When using VFS, a programmer doesn't need to know the intricacies of each driver to work with them.

  • Spool directory This is the directory that stores the files for queued-up jobs. There is either one big directory or a separate directory for each queue or class.

  • Print filters A print filter is a program that inserts control codes for a printer into a document before it is transferred to the printer. An example is inserting the PCL code for landscape output into the beginning of a document to tell the printer to print the page in landscape format. Filters can also be used to translate a job from one printer language to another. For example, a Ghostscript print filter could be used to change an ASCII text file into PostScript.

  • Banner or header page A banner is a page that prints before a print request to delineate jobs and identify the characteristics specific to that job.

  • Transfer script (backend) A script or program used to transfer a print request to a print device. These can be simple transfer programs, or they can have more complex features such as device status checking.

  • Footer page A footer is a page that prints after a print request to delineate jobs and identify the characteristics specific to that job.

  • Contention Depending on the printer type, device contention can be a major issue. With local printers, only one print request can be printed at a time. If two print requests were trying to print on a serial printer at the same time, you would either have interleaved jobs or missing pages. A spooler allows jobs to wait serially for the printer resource to become free. For local printers (serial, USB, parallel), you should define only one queue for each printer. If you have more than one queue for a local printer, the queues can interfere with each other's print requests. With remote, IPP, and network printing, you can define multiple print queues for each printer because these devices are built to handle requests from multiple systems at the same time.

  • Vector vs. raster graphics Raster graphics are more commonly know as bitmaps. This graphics format assembles the data in a rectangular grid of pixels, each with an assigned color. Common file formats that use raster graphics include GIF, TIFF, BMP, and JPEG, among others. They are generally considered photorealistic, but resizing them can cause jaggedness as the pixel size increases. Most printers are raster-based, so any vector-based graphic is usually translated into a bitmap before printing. Suppose the smiley face in the top-left corner of Figure 11-2 is an RGB bitmap image. When zoomed in, it might look like the big smiley face to the right. Every square represents a pixel. Zoomed in further, we see three pixels whose colors are constructed by adding the values for red, green, and blue.

    Figure 11-2. An example of raster graphics

    Vector graphics use geometric shapes to build an image. All the images are composed of lines that are defined by a series of mathematical equations. Vector graphics files are generally smaller than raster files. Vector graphics can be resized to almost any size without jaggedness because they are formula-based. Common file formats for vector graphics include PDF, EPS, and others. Plotters can directly print vector graphics. In Figure 11-3, the image on the right is stripped of color and shows the raw geometric shapes. Each shape is represented by a distinct mathematical equation.

    Figure 11-3. An example of vector graphics



Linux Troubleshooting for System Administrators and Power Users
Real World Mac Maintenance and Backups
ISBN: 131855158
EAN: 2147483647
Year: 2004
Pages: 129
Authors: Joe Kissell

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net