First, let’s begin with the meaning of the term “spooling”: sometimes the size of a document is larger than the printer’s memory, so “printer spooling” allows the sending of multiple documents to a printer and putting all theses documents in a queue.
Now, under Unix there are two printing systems:
- The BSD spooling system uses
lpd daemon to schedule the print jobs.
- The SVR4 spooling system uses
lpsched as the scheduler.
Jeff Lessem’s USAIL: Unix system administration independent learning has a section on Printing under Unix which provides a good overview of both the BSD and SVR4 systems:
The BSD spooling system
extends well to large, heterogeneous networks allowing many computers to
share printers.
Under the BSD spooling system, access to printers is controlled by lpd
daemon and the lpr program. lpr is the only program on a BSD system that
can queue files for printing.
lpr accepts data to be printed, puts it in a spooling directory, and
notifies the lpd daemon. For each print job, lpr creates two
files, a control file (cfxxx) and a data file (dfxxx) in the spool
directory, xxx indicating a unique job-id. The control file contains
the information for handling the print job, including the identity of
the owner. The data file contains the actual data to be printed.
The lpd daemon checks the /etc/printcap file to identify the
destination printer. If the destination printer is a local device,
lpd makes sure a copy of the lpd daemon is running on that print
queue. Otherwise lpd opens a connection to the remote host to which
the printer is connected and transfers both the control and data file
to it.
Print jobs are scheduled by lpd on a First-In, First-Out (FIFO)
basis. However, the system administrator may use the lpc command to
alter the priority of the jobs in the print queue.
SVR4 spooling system is used by Solaris and HP-UX. It offers more control
and flexibility but was not designed for network printing and is more
complicated to set up.
Under SVR4 spooling system, the lp command accepts the data to be
printed, makes a copy of it in the spool directory associated with the
destination. The destination consists of a printer name and an optional
specification of a class to which the printer belongs. When the specified
printer is busy the job is sent to another printer in the same class. The
spool directory is normally /var/spool/lp/request/printer-name and the
print file is given a unique name to identify both the job and the user.
Access to the printer is controlled by lpsched daemon. It picks up
the jobs from the spool directory and sends them to appropriate
destination when it becomes available. lpsched also keeps a log,
usually in /usr/spool/lp/log. The log file would indicate any error
in processing the print jobs, as well as the user-name,
See also: Printers and printer spooler – lp, lpstat and cancel commands | Tips & Tricks for IT's Blog