Using the lpq Command to Check the Status of Print Jobs


Using the lpq Command to Check the Status of Print Jobs

The lpq command can be used to check the status of jobs that are waiting in the print queue. If it is called without any arguments, lpq will report the status of all jobs currently in the queue for the default printer. If the PRINTER environment variable is set, that printer is considered to be the default printer. If the PRINTER environment variable is not set, the printer that is aliased to lp in /etc/printcap will be used as the default.

lpq can also be called with a job number to show only the status of a particular job or with a username to show only the status of jobs owned by a particular user. The output of lpq will look something like this:

# lpq -P samsunginkjet samsunginkjet is ready and printing Rank      Owner    Job    Files                           Total Size active    frank    5      /home/btman/sample.txt          2000 bytes 2nd       frank    6      /home/btman/sample1.txt         2500 bytes 3rd       jack     7      /home/jack/myfile.txt           3200 bytes 4th       jack     8      ...                             5500 bytes


The -P option tells lpq to report on a printer other than the defaultin this case, the printer named samsunginkjet. All of the options to lpq will be explained later.

The first line in the output from lpq tells you what the printer is currently doing. In this case, the printer is ready and printing. If the printer is stalled, out of paper, jammed, and so on, lpq will report that status instead.

The example here shows four jobs in the queue; one is active, and the others are ranked as to when they will be printed. A few other things are worth pointing out. The third column, labeled Job, shows the ID number assigned to a particular job. If you need to cancel a print job (explained later), you will need this job ID number. Also, the fourth column lists the file or files that are being printed. Notice that the fourth job in this example is listed as just three dots. This means that the pathname of the file is too long to fit in the list, so lpq simply didn't list it.

The lpq command has a few other options, as shown in Table 17.4.

Table 17.4. Options to lpq

Option

Description

-P name

Here, name is the name of a printer. This will cause lpq to show information on a printer other than the default one.

-l

This option will cause information about each one of the files in the queue to be displayed, even if the information causes the display to break across a line. (In the previous example, this command would cause the filename to show; it currently shows up as three dots because it's too long to fit.)

-a

Causes lpq to display the status of all local queues for all printers.





FreeBSD 6 Unleashed
FreeBSD 6 Unleashed
ISBN: 0672328755
EAN: 2147483647
Year: 2006
Pages: 355
Authors: Brian Tiemann

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