LP Print Service Commands
The following table lists frequently used LP print service commands. You must be root, lp, or assume an equivalent role to use the 1M commands.
Table 8-7 Quick Reference to LP Print Service Commands
Command | Man Page | Task |
---|---|---|
enable | enable(1) | Activate a printer |
cancel | cancel(1) | Cancel a print request |
lp | lp(1) | Send one or more file(s) to a printer |
lpstat | lpstat(1) | Report the status of the LP print service |
disable | enable(1) | Deactivate one or more printers |
accept | accept(1M) | Permit print requests to be queued for a specific destination |
reject | accept(1M) | Prevent print requests from being queued for a specific destination |
lpadmin | lpadmin(1M) | Set up or change printer configuration |
lpfilter | lpfilter(1M) | Set up or change filter definitions |
lpforms | lpforms(1M) | Set up or change preprinted forms |
lpadmin | lpadmin(1M) | Mount a form |
lpmove | lpmove(1M) | Move output requests from one destination to another |
lpsched | lpsched(1M) | Start the LP print service scheduler |
lpshut | lpshut(1M) | Stop the LP print service scheduler |
lpusers | lpusers(1M) | Set or change the default priority and priority limits that can be requested by users of the LP print service |
Functions of the LP Print Service
The LP print service performs the following functions:
Administers files and schedules local print requests
Receives and schedules network requests
Filters files (if necessary) so they print properly
Starts programs that interface with the printers
Tracks the status of jobs
Tracks forms mounted on the printer
Tracks print wheels currently mounted
Delivers alerts to mount new forms or different print wheels
Delivers alerts about printing problems
How LP Administers Files and Schedules Local Print Requests
The LP print service has a scheduler daemon called lpsched. The scheduler daemon updates the LP system files with information about printer setup and configuration.
The lpsched daemon schedules all local print requests on a print server, as shown in the following figure, whether users issue the requests from an application or from the command line. Also, the scheduler tracks the status of printers and filters on the print server. When a printer finishes a request, the scheduler schedules the next request, if there is one, in the queue on the print server.
Figure 8-1 The lpsched Daemon Schedules Local Print Requests
Each print server must have only one LP scheduler running. The scheduler is started when a system is booted (or enters run level 2) by the /etc/rc2.d/S80lp control script. Without rebooting the systems, you can stop the scheduler with the /etc/init.d/lp stop command and restart the scheduler with the /etc/init.d/lp start command. The scheduler for each system manages requests issued to the system by the lp commands.
Scheduling Network Print Requests
Each print client communicates directly with a print sever over the network. The communication is done between the requesting command (lp, lpstat, cancel, lpr, lpq, or lprm) and the print service on the print server. Doing so, reduces the print system overhead on client only systems, improving scalability, performance and accuracy of data.
Print servers listen for print request with the Internet services daemon (inetd). Upon hearing a request for print service from the network, the inetd daemon starts a program called the "protocol adaptor" (in.lpd). The protocol adaptor translates the print request and communicates it to the print spooler, returning the results to the requester. It starts on demand and exits when it has serviced the network request. This eliminates idle system overhead for printing. It also eliminates any additional system configuration for network printing support as was the case in previous versions of Solaris printing.
Filtering Print Files
Print filters are programs on the print server that convert the content of a queued file from one format to another.
A print filter can be as simple or as complex as needed. The SunOS release provides print filters in the /usr/lib/lp/postscript directory that cover most situations where the destination printer requires the data to be in PostScript format. If you need filters for non-PostScript printers, you have to create the filters and add them to the systems that need them.
A set of print filter descriptor files are provided in the /etc/lp/fd directory. These descriptor files describe the characteristics of the filter (for example, fast or slow filter), and point to the filter program (for example, /usr/lib/lp/postscript/postdaisy).
What the Printer Interface Program Does
The LP print service interacts with other parts of the operating system. It uses a standard printer interface program to:
Initialize the printer port, if necessary. The standard printer interface program uses the stty command to initialize the printer port.
Initialize the printer. The standard printer interface program uses the terminfo database and the TERM shell variable to find the appropriate control sequences.
Print a banner page, if necessary.
Print the correct number of copies specified by the print request.
The LP print service uses the standard interface program (found in the /usr/lib/lp/model directory) unless you specify a different one. You can create custom interface programs, but you must make sure that the custom program does not terminate the connection to the printer or interfere with proper printer initialization.
How the lpsched Daemon Tracks the Status of Print Requests
The lpsched daemon keeps a log of each print request that it processes and notes any errors that occur during the printing process. This log is kept in the /var/lp/logs/lpsched file. Every night, the lp cron job renames the /var/lp/logs/lpsched file to a new lpsched.n file and starts a new log file. If errors occur or jobs disappear from the print queue, you can use the log files to determine what the lpsched daemon has done with a printing job.
Cleaning Out Log Files
The lpsched and requests log files in the /var/lp/logs directory grow as information is appended. The LP print service uses a default cron job to clean out the log files. The lp cron job is located in the /var/spool/cron/crontabs/lp file. It periodically moves the contents of the log files. The contents of log are moved to log.1, and the contents of log.1 are moved to log.2. The contents of log.2 are lost (that is, replaced by the former contents of log.1) when log.2 gets overwritten.
How to Change Frequency of Printer Request Log Rotation
Starting with the Solaris 2.6 release, the requests log file on the printer server is rotated weekly rather than daily. You can change the rotation interval back to daily if the printer server is busy.
Become superuser or lp on the printer server.
Set the EDITOR environment variable.
# EDITOR=vi # export EDITOR
Edit the lp crontab file.
# crontab -e lp
Change the first line of the file which rotates the requests log files every Sunday (0) to an asterisk (*) for daily rotation:
13 3 * * * cd /var/lp/logs; if [ -f requests ]; then if [ -f requests.1 ]; then /bin/mv requests.1 requests.2; fi; /usr/bin/cp requests requests.1; >requests; fi
Save the file and exit.