lpq Command

The lpq command includes information for the AIX® Print Subsystem lpq and the System V Print Subsystem lpq.

AIX Print Subsystem lpq Command

Purpose

Examines the spool queue.

Syntax

lpq [ + [ Number ] ] [ -l | -W ] [ -P Printer ] [ JobNumber ] [ UserName ]

Description

The lpq command reports the status of the specified job or all jobs associated with the specified UserName and JobNumber variables. JobNumber variable specifies the number of the job in the spool queue that you want to view. A UserName variable specifies viewing the jobs for the name of the person who submitted the job to that queue.

The lpq command reports on any jobs currently in the default queue when invoked without any options. Parameters supplied that are not recognized as parameters are interpreted as user names or job numbers to filter out only those jobs of interest.

For each job submitted (each job called by the lpr command), the lpq command reports the user's name, current rank in the queue, the name of the job, the job identifier (a number that can be supplied to the lprm command for removing a specific job), and the total size in blocks. Normally, only as much information as will fit on one line is displayed. Job ordering depends on the algorithm used to scan the spooling directory and is supposed to be FIFO (first-in-first-out). File names making up a job may be unavailable (when the lpr command is used as a sink in a pipeline). In this case, the file is indicated as - (standard input).

The display generated by the lpq command contains two entries for remote queues. The first entry contains the client's local queue and local device name and its status information. The second entry follows immediately; it contains the client's local queue name (again), followed by the remote queue name. Any jobs submitted to a remote queue are displayed first on the local side and are moved to the remote device as the job is processed on the remote machine.

Since the status commands communicate with remote machines, the status display may occasionally appear to hang while waiting for a response from the remote machine. The command will eventually time out if a connection cannot be established between the two machines.

Flags

Item Description
-l Generates the long output format.
+ [ Number ] Displays the spool queue until it empties. A Number variable is the time in seconds before the display regenerates.
-P Printer Displays the spool queue for the printer specified by the Printer variable.
Note: Any destination command line options override both the LPDEST and the PRINTER environment variables.
-W Displays a wide version of status information with longer queue names, device names, and job numbers. Longer job number information is available on AIX 4.3.2 and later. This flag cannot be used with the -l flag. If the -l flag and the -W flag are used simultaneously, the first one specified takes precedence.

Security

Attention RBAC users and Trusted AIX users: This command can perform privileged operations. Only privileged users can run privileged operations. For more information about authorizations and privileges, see Privileged Command Database in AIX Version 7.1 Security. For a list of privileges and the authorizations associated with this command, see the lssecattr command or the getcmdattr subcommand.

Examples

  1. To display a job number in the print queue lp0, enter:

    lpq  -P lp0

    This command displays a list similar to the following:

    Queue    Dev      Status    Job    Files    User      PP    %      Blks    CP    Rnk
    lp0       dlp0    running   39      motd     guest    10    83      12      1     1
  2. To display the status of the default queue in wide format for AIX 4.3.2 or later, enter:

    lpq  -W

Files

Item Description
/usr/bin/lpq Contains the lpq command.
/usr/sbin/qdaemon Contains the queuing daemon.
/etc/qconfig Contains the queue configuration file.
/etc/qconfig.bin Contains the digested, binary version of the /etc/qconfig file.
/var/spool/lpd/qdir/* Contains queue requests.
/var/spool/lpd/stat/* Contains information on the status of the devices.
/var/spool/qdaemon/* Contains temporary copies of enqueued files.

Related Information

The lpr command, lprm command, lpstat command, qchk command.

The qconfig file.

Checking print job status (qchk command) in AIX Version 7.1 Operating system and device management.

Printers, print jobs, and queues in AIX Version 7.1 Operating system and device management.

Print spooler in theAIX Version 7.1 Printers and printing.

System V Print Subsystem lpq Command

Purpose

(BSD) Displays the queue of printer jobs

Syntax

/usr/bin/lpq [-Pprinter] [-l] [+ [interval] ] [job# ... ] [username ... ]

Description

The lpq command displays the contents of a printer queue. It reports the status of jobs specified by job#, or all jobs owned by the user specified by username. lpq reports on all jobs in the default printer queue when invoked with no arguments.

For each print job in the queue, lpq reports the user's name, current position, the names of input files comprising the job, the job number (by which it is referred to when using lprm) and the total size in bytes. Normally, only as much information as will fit on one line is displayed. Jobs are normally queued on a first-in-first-out basis. Filenames comprising a job may be unavailable, such as when lpr is used at the end of a pipeline; in such cases the filename field indicates the standard input.

If lpq warns that there is no daemon present (that is, due to some malfunction), the lpc command can be used to restart a printer daemon.

Output formatting is sensitive to the line length of the terminal; this can result in widely-spaced columns.

Flags

-P printer
Display information about the queue for the specified printer. In the absence of the -P flag, the queue to the printer specified by the PRINTER variable in the environment is used. If the PRINTER variable is not set, the queue for the default printer is used.
-l
Display queue information in long format; includes the name of the host from which the job originated.
+[interval ]
Display the spool queue periodically until it empties. This option clears the terminal screen before reporting on the queue. If an interval is supplied, lpq sleeps that number of seconds in between reports.

Security

Attention RBAC users and Trusted AIX users: This command can perform privileged operations. Only privileged users can run privileged operations. For more information about authorizations and privileges, see Privileged Command Database in AIX Version 7.1 Security. For a list of privileges and the authorizations associated with this command, see the lssecattr command or the getcmdattr subcommand.

Files

/var/spool/lp
spooling directory.
/var/spool/lp/tmp/system_name/*-0
request files specifying jobs

Error Codes

lpq: printer is printing
The lpq program queries the spooler LPSCHED about the status of the printer. If the printer is disabled, the system administrator can restart the spooler using lpc.
lpq: printer waiting for auto-retry (offline ?)
The daemon could not open the printer device. The printer may be turned off-line. This message can also occur if a printer is out of paper, the paper is jammed, and so on. Another possible cause is that a process, such as an output filter, has exclusive use of the device. The only recourse in this case is to kill the offending process and restart the printer with lpc.
lpq: waiting for host to come up
A daemon is trying to connect to the remote machine named host, in order to send the files in the local queue. If the remote machine is up, lpd on the remote machine is probably dead or hung and should be restarted using lpc.
lpq: sending to host
The files are being transferred to the remote host, or else the local daemon has hung while trying to transfer the files.
lpq: printer disabled reason:
The printer has been marked as being unavailable with lpc.
lpq: The LP print service isn't running or can't be reached.
The lpsched process overseeing the spooling queue does not exist. You can restart the printer daemon with lpc.
lpq: printer: unknown printer
The printer was not found in the System V LP database. Usually this is a typing mistake; however, it may indicate that the printer does not exist on the system. Use lpstat -p to find the reason.
lpq: error on opening queue to spooler
The connection to lpsched on the local machine failed. This usually means the printer server started at boot time has died or is hung. Check if the printer spooler daemon /usr/lib/lp/lpsched is running.
lpq: Can't send message to LP print service
lpq: Can't establish contact with LP print service
These indicate that the LP print service has been stopped. Get help from the system administrator.
lpq: Received unexpected message from LP print service
It is likely there is an error in this software. Get help from system administrator.