UNIX System Administration Handbook - Evi Nemeth [426]
Table 23.3 System V printing commands
Destinations and classes
Each destination has a name that consists of up to 14 alphanumeric characters and underscores. In addition to being named, a destination can belong to zero or more classes. As in BSD printing, a destination does not have to be a printer, although in practice it usually is. For example, a destination could be an ordinary text file that needs to be appended to by many users. The printing system could be used to avoid a situation in which two people attempt to add to the file at the same time.
A class is a group of destinations that all serve the same purpose in some way. For example, if a site had two printers in the same room, they could be placed in a class. Likewise, two printers with similar features (such as color, resolution, duplex, or speed) might be grouped into a class. lpsched would direct output for that class to whichever printer became available first. Class names have the same restrictions as destination names.
In the rest of this chapter we use the words “printer” and “destination” interchangeably to refer to destinations, even though a destination is not necessarily a printer.
A brief description of lp
lp is a user-level command that queues data for printing. lp makes a copy of the data to be printed (which can come either from named files or from lp’s standard input) and places it in a file or set of files in the spool directory. Under HP-UX, the spool directory for a destination is /var/spool/lp/request/dest where dest is the name by which lp knows the printer or class of printers. Solaris uses the pluralized version, /var/spool/lp/requests/dest.
The spool file(s) are named xxxn, where n is a job identification number assigned by lp and xxx varies from system to system. This filename identifies the job both to the user and internally to the printing system. We refer to this name as the job identification or jobid, for short.
If the -d destination option is specified to lp, the input is queued for output to the specified destination, where destination is either a printer or a class. If the -d option is not used, lp uses the contents of the LPDEST environment variable as the name of the output destination. If this environment variable is not set, lp queues the data for output to the default destination if one exists or rejects the request if there is no default destination. (The default destination is set with lpadmin -d.)
In Solaris, if no default device is specified with lpadmin -d, then lp searches the ~/.printers file, the /etc/printers.conf file, and finally, the Federated Naming Service3
for a default destination.
lpsched and lpshut: start and stop printing
The lpsched daemon sends the files placed in the spool directory by lp to an appropriate device as soon as one is available. lpsched keeps a log of each file it processes and any errors that occur. In Solaris, the default log file is /var/lp/logs/lpsched.
When the HP-UX lpsched is started (usually at boot time), it moves its default log file from /var/adm/lp/log to /var/adm/lp/oldlog and starts a new log file.
A log file looks something like this:
***** LP LOG: Jul 6 12:05 *****
pr1-107 garth pr1 Jul 6 12:10
pr-112 scott pr1 Jul 6 12:22
pr-117 evi pr2 Jul 6 12:22
pr1-118 garth pr1 Jul 6 12:25
pr1-119 garth pr1 Jul 6 13:38
pr-132 evi pr1 Jul 6 13:42
The first column is the jobid of each job. The second column is the user who requested the job. The third column is the actual printer the job was sent to, and the last column is the time at which the job was queued.
On the HP-UX system in this example, there are two printers: pr1 and pr2, both of which are in the class pr. The user garth always specified the specific printer pr1, so that’s where his jobs were always