Académique Documents
Professionnel Documents
Culture Documents
Skill Level: Intermediate Adam Cormany Systems Architect Scientific Games Corporation
29 Jun 2010 Learn how to use the AIX command line to configure and manage print queues easily. IBM has created intuitive commands that assist IBM AIX administrators in configuring and managing print queues easily. The System Management Interface Tool (SMIT) offers a menu-driven interface to manage print queues. However, if you're interested in learning to use the command line for such things, this article outlines the AIX print queue files and provides a few commands for managing them.
AIX A-Z: Managing printing on AIX Copyright IBM Corporation 2010. All rights reserved.
Trademarks Page 1 of 17
developerWorks
ibm.com/developerWorks
-rw-rw-r--rw-rw----
1 root 1 root
printq printq
The /etc/qconfig file contains detailed configuration information on print queues and print devices. The file is structured in stanzas, or a block of parameters and values under a single main keyword. For every queue stanza, at least one device stanza immediately follows. The /etc/qconfig structure is shown in Listing 2. Listing 2. /etc/qconfig stanza structure
<queue name>: <queue parameter> = <queue parameter value> <device>: <device parameter> = <device parameter value>
Table 1 shows the parameters and possible values that can be used inside the /etc/qconfig file. These parameters define a print queue. Table 1. /etc/qconfig parameters and values
Parameter acctfile Description Write print accounting information to <acctfile> if it exists. Name of the device stanza. Printing priority order. Values <filename> Default FALSE (no accounting)
device
<device stanza name> fcfs (first come, first served) sjn (shortest jobs first)
discipline
up
Queue status.
TRUE
recovery_type
queuedown (Leave the queuedown queue down until manual intervention takes place.) runscript <script> (Execute <script>.) retry -T <min> -R <n> (Attempt to re-enable the queue
AIX A-Z: Managing printing on AIX Copyright IBM Corporation 2010. All rights reserved.
Trademarks Page 2 of 17
ibm.com/developerWorks
developerWorks
after <min> minutes. If the queue isn't re-enabled successfully, try again in <min> and repeat <n> times before giving up.) sendmail <user> (E-mail <user> that the queue is down.)
The parameters listed in Table 2 define a remote print queue. Table 2. Parameters for a remote print queue
Parameter host s_statfilter Description Values Host in which the remote queue <hostname> or <IP> is located Queue status format (short version format) /usr/lib/lpd/bsdshort (BSD remote system) /usr/lib/lpd/aixv2short (RT remote system) /usr/lib/lpd/attshort (AT&T remote system) l_statfilter Queue status format (long version format) /usr/lib/lpd/bsdlong (BSD remote system) /usr/lib/lpd/aixv2long (RT remote system) /usr/lib/lpd/attslong (AT&T remote system) rq Remote queue name <queue name>
The parameters shown in Table 3 define a print device. Table 3. Parameters for a print device
Parameter access Description Back-end access to <FILE> Values WRITE (Write access) BOTH (Read and Write access) align Send a form-feed TRUE (Send form-feed.) TRUE control if the printer was idle. FALSE (Don't send form-feed.) Default WRITE
AIX A-Z: Managing printing on AIX Copyright IBM Corporation 2010. All rights reserved.
Trademarks Page 3 of 17
developerWorks
ibm.com/developerWorks
backend feed
Advance N pages if the <N> (Advance N printer goes idle. pages.) FALSE (Don't advance any pages.)
file
FALSE
header
NEVER (Don't print header pages.) ALWAYS (Always print header pages.) GROUP (Print header pages for multiple print jobs by the same user.)
NEVER
trailer
NEVER (Don't print header pages.) ALWAYS (Always print header pages.) GROUP (Print header pages for multiple print jobs by the same user.)
NEVER
To make sense of all these parameters, Listing 3 provides an example of a simple print queue and device that could be found in AIX's /etc/qconfig file. Listing 3. /etc/qconfig example
pac22_ps: device = hp@pac22 hp@pac22: file = /var/spool/lpd/pio/@local/dev/hp@pac22#hpJetDirect#9100 header = never trailer = never access = both backend = /usr/lib/lpd/pio/etc/piojetd pac22 9100
It looks like the queue named pac22_ps is using device hp@pac22. As far as device hp@pac22 itself, header and trailer pages are disabled, the device can both read and write to file /var/spool/lpd/pio/hp@pac22#hpJetDirect#9100, and is using back-end file /usr/lib/lpd/pio/etc/piojetd (JetDirect) on port 9100. The file /etc/qconfig.bin is a binary version of /etc/qconfig and is used by a command named qdaemon, which schedules printing jobs via the command enq.
AIX A-Z: Managing printing on AIX Copyright IBM Corporation 2010. All rights reserved.
Trademarks Page 4 of 17
ibm.com/developerWorks
developerWorks
Good. The print job that I created is there and queued. Now, look to see what files are in /var/spool/lpd/qdir:
# ls -l /var/spool/lpd/qdir total 24 -rw-rw---- 1 root printq -rw-rw---- 1 root printq -rw-rw---- 1 root printq
1663 Mar 03 13:47 n0cormany:pac22_ps$#@!EgEc 1913 Mar 03 13:40 n0root:pac22_ps$#@!3iEc 1919 Mar 03 13:44 n0root:pac22_ps$#@!Ybyc
AIX A-Z: Managing printing on AIX Copyright IBM Corporation 2010. All rights reserved.
Trademarks Page 5 of 17
developerWorks
ibm.com/developerWorks
It's easy in this example to discern which file belongs to the print job I just sent, but what if the print queue has been down for hours and hundreds of print jobs are queued and waiting to print? One method you can use to find which file you need is by looking at the file name listed in lpstat t. In this example, the file t1ZEgEa was created under /var/spool/qdaemon. By looking at the characters 4 through 6 of the file name (for example, EgE), you can surmise n0cormany:pac22_ps$#@!EgEc is what you want to look at. Listing 5 shows the messy output. Listing 5. Print job environment information
# cat 'n0cormany:pac22_ps$#@!EgEc' 000001167 #@%!: 0 0 15 0 0 1267642023 1 1 3 3 cormany 0 REAL_USER=cormanyLOGIN_USER=rootREAL_GROUP=atcGROUPS=atc, support,sshd AUDIT_CLASSES=RLIMIT_CPU=9223372036854775807 RLIMIT_FSIZE=18014398509481984 RLIMIT_DATA=18014398509481984 RLIMIT_STACK=8388608 RLIMIT_CORE=18014398509481984 RLIMIT_RSS=18014398509481984 RLIMIT_NOFILE=9223372036854775807 RLIMIT_THREADS=9223372036854775807 RLIMIT_NPROC=9223372036854775807 RLIMIT_CPU_HARD=9223372036854775807 RLIMIT_FSIZE_HARD=18014398509481984 RLIMIT_DATA_HARD=18014398509481984 RLIMIT_STACK_HARD=8388608 RLIMIT_CORE_HARD=18014398509481984 RLIMIT_RSS_HARD=18014398509481984 RLIMIT_NOFILE_HARD=9223372036854775807 RLIMIT_THREADS_HARD=9223372036854775807 RLIMIT_NPROC_HARD=9223372036854775807 UMASK=22 PAG_DATA= USRENVIRON:_=/usr/bin/lp LANG=en_US LOGIN=cormany G_BROKEN_FILENAMES=1 VISUAL=vi XREMOTETMPDIR=/home/cormany PATH=/usr/bin:/etc:/usr/sbin:/usr/ucb:/bin:/usr/bin/X11:/sbin: /usr/java5/jre/bin:/usr/java5/bin:/usr/ushare/bin:/usr/local/bin:.: LC__FASTMSG=true EDITOR=vi HISTFILE=/home/cormany/history_1040542 LOGNAME=cormany MAIL=/usr/spool/mail/cormany LOCPATH=/usr/lib/nls/locPS1=# USER=cormany AUTHSTATE=NIS SHELL=/bin/ksh ODMDIR=/etc/objrepos HISTSIZE=100 HOME=/home/cormany TERM=xterm MAILMSG=[YOU HAVE NEW MAIL]
AIX A-Z: Managing printing on AIX Copyright IBM Corporation 2010. All rights reserved.
Trademarks Page 6 of 17
ibm.com/developerWorks
developerWorks
This information may look like garbage, but it can be very useful. An administrator can view this file and try to discern why a print job has failed by looking at the users environment, which is included in the file. The second directory is /var/spool/lpd/stat. As its name references, this directory contains status information on the print devices. Each device will have a file in this directory. Unfortunately, the files are not in ASCII format, so there is little to view here, but its good to know where these files reside. The third and final directory in /var/spool/lpd is /var/spool/lpd/pio. This directory contains information on the back end that qdaemon uses. This is where the print queue typically reads and writes its back-end data. The directory /var/spool/qdaemon is an important directory in the printing process on AIX. It contains a copy of the actual file being printed, as Listing 6 shows. Listing 6. /var/spool/qdaemon files
# ls -l /var/spool/qdaemon total 24 -rw-r----1 cormany printq -rw-r----1 root printq -rw-r----1 root printq # cat /var/spool/qdaemon/t1ZEgEa test3
developerWorks
ibm.com/developerWorks
# mkque -q AMDC79 -a 'recovery_type = sendmail cormany' # lpstat -W Queue -------------------pac22_ps atc04_pcl AMDC79 Dev -------------hp@pac22 hp@atc04 dumm Status Job Files User Blks Rnk --------- ------ ------------------ -------- ---- --READY READY UNKNOWN
The file /etc/qconfig now contains the new queue and device shown in Listing 9. Listing 9. New queue information in /etc/qconfig
AMDC79: device = hp@pac22 recovery_type = sendmail cormany pa@pac22: header = always backend = /usr/lib/lpd/pio/etc/piojetd pac22 9100
AIX A-Z: Managing printing on AIX Copyright IBM Corporation 2010. All rights reserved.
Trademarks Page 8 of 17
ibm.com/developerWorks
developerWorks
Now, change the queue's device attribute header to group and add the attribute trailer:
# chquedev -q AMDC79 -d hp@pac22 -a 'header = group' -a 'trailer = group'
AIX A-Z: Managing printing on AIX Copyright IBM Corporation 2010. All rights reserved.
Trademarks Page 9 of 17
developerWorks
ibm.com/developerWorks
Like most commands in AIX, there are several ways to accomplish the same task. Viewing information from /etc/qconfig is no different. The preferred and safer method of viewing queue and queue device information is to use lsque and lsquedev. By using lsque, you see the queue information only as follows:
# lsque -q AMDC79 AMDC79: device = hp@qaljlab3 recovery_type = runscript /home/cormany/fix_printer
By using lsquedev on the print queue in the code above, you'll see the device queue information only as shown below:
# lsquedev -q AMDC79 -d hp@pac22 hp@pac22: trailer = group header = group backend = /usr/lib/lpd/pio/etc/piojetd pac22 9100
Another handy option in both lsque and lsquedev is the ability to create colon-delimited output of the queue and queue device. This format of output can be useful if scripting print-management functions. Listing 11 shows the output of lsque and lsquedev. Listing 11. lsque and lsquedev delimited output
# lsque -q AMDC79 -c #name:device:discipline:up:acctfile:host:s_statfilter:l_statfilter:rq AMDC79:hp@pac22:fcfs:TRUE:FALSE:::: # lsquedev -q AMDC79 -d hp@qaljlab3 -c #name:file:access:feed:header:trailer:backend:align hp@pac22:FALSE:write:never:group:group:/usr/lib/lpd/pio/etc/piojetd pac22 9100:FALSE
AIX A-Z: Managing printing on AIX Copyright IBM Corporation 2010. All rights reserved.
Trademarks Page 10 of 17
ibm.com/developerWorks
developerWorks
Status Job Files User Blks Rnk --------- ------ ------------------ -------- ---- --READY READY
Status Job Files --------- ------ -----------------READY READY DOWN QUEUED 1169 STDIN.1134828 QUEUED 1171 STDIN.1134838 QUEUED 1172 STDIN.1134840 QUEUED 1173 STDIN.1134842 QUEUED 1174 STDIN.1134844 QUEUED 1175 STDIN.1134846 QUEUED 1176 STDIN.1134592
1 1 1 1 1 1 1
1 2 3 4 5 6 7
First, verify the variable PRINTER is set to AMDC79. Then, select the print job you want to terminate (1169) and cancel it. Listing 14 shows the code. Listing 14. Canceling a single print job
# echo $PRINTER AMDC79 # cancel 1169 # lpstat -W Queue -------------------pac22_ps atc04_pcl AMDC79
Status Job Files --------- ------ -----------------READY READY DOWN QUEUED 1171 STDIN.1134838 QUEUED 1172 STDIN.1134840 QUEUED 1173 STDIN.1134842 QUEUED 1174 STDIN.1134844 QUEUED 1175 STDIN.1134846 QUEUED 1176 STDIN.1134592
1 1 1 1 1 1
2 3 4 5 6 7
AIX A-Z: Managing printing on AIX Copyright IBM Corporation 2010. All rights reserved.
Trademarks Page 11 of 17
developerWorks
ibm.com/developerWorks
This is good; the first print job was removed, but the queue is still down. Now, remove jobs 1171, 1173, and 1176. Listing 15 shows the code. Listing 15. Canceling multiple print jobs
# cancel 1171 1173 1176 # lpstat -W Queue Dev -------------------- -------------pac22_ps hp@pac22 atc04_pcl hp@atc04 AMDC79 hp@pac22
Status Job Files --------- ------ -----------------READY READY DOWN QUEUED 1172 STDIN.1134840 QUEUED 1174 STDIN.1134844 QUEUED 1175 STDIN.1134846
1 1 1
3 5 6
From there, you can terminate the rest of them. Listing 16 shows the code. Listing 16. Canceling the entire print queue
# cancel AMDC79 # lpstat -W Queue -------------------pac22_ps atc04_pcl AMDC79
Status Job Files User Blks Rnk --------- ------ ------------------ -------- ---- --READY READY DOWN
Status Job Files User Blks Rnk --------- ------ ------------------ -------- ---- --READY READY DOWN
AIX A-Z: Managing printing on AIX Copyright IBM Corporation 2010. All rights reserved.
Trademarks Page 12 of 17
ibm.com/developerWorks
developerWorks
atc04_pcl AMDC79
hp@atc04 hp@pac22
READY READY
To re-enable the print queue, simply type enable <print queue>.</print>. Easy, eh? But waitthe department has received word that the print queue is back up, and now they're sending hundreds of jobs to it. That's great, right? Next phone call you receive is from the support staff saying that there's another issue they didn't see with the printer. Now, you have hundreds of jobs coming through the print queue, and you need to terminate the jobs and disable the printer immediately! Don't panic: disable can do the job for you. By supplying the switch c to disable all print jobs in the queue, the jobs are removed and the queue is disabled. Whew, that was a close one! Listing 18 shows the code. Listing 18. Disabling the print queue
# disable c AMDC79 # lpstat -W Queue -------------------pac22_ps atc04_pcl AMDC79
Status Job Files User Blks Rnk --------- ------ ------------------ -------- ---- --READY READY DOWN
AIX A-Z: Managing printing on AIX Copyright IBM Corporation 2010. All rights reserved.
Trademarks Page 13 of 17
developerWorks
ibm.com/developerWorks
-W. View the output, showing longer names of queues, devices, and so on. -w <seconds>. Refresh output every <seconds> seconds until the queue is empty. As a reminder regarding the q switch displaying the default printer, in AIX the default printer is the queue first in /etc/qconfig. One handy usage of qchk is to watch print jobs sent by a user or to view a specific print job. For example, a user named Xander has sent a few jobs to a print queue and claims he isn't getting his printouts when another user named Paul has gotten his earlier in the day. To quickly and easily find all print jobs sent by Xander, you could use qchk, as shown in Listing 19. Listing 19. View print jobs by user
# qchk -u xander Queue Dev Status ------- ----- --------pac22_p hp@pa DOWN QUEUED QUEUED QUEUED QUEUED QUEUED
Job Files User PP % Blks Rnk --- ------------------ ---------- ---- -- ----- --191 192 193 194 195 tmp1238 tmp1323 tmp1347 tmp1789 tmp9831 xander xander xander xander xander 4 4 4 4 4 1 1 1 1 1
Found them! As Xander said, none of his print jobs have gone through. It looks like the printer queue is down and some troubleshooting is needed. After a quick phone call, you find out that the printer ran out of paper. After the paper has been replenished and the queue has been re-enabled, all of Xander's print jobs have printed successfully. Now, verify that Xander isn't waiting on any other print jobs:
# qchk -u xander Queue Dev Status Job Files User PP % Blks Rnk ------- ----- --------- --- ------------------ ---------- ---- -- ----- --pac22_p hp@pa READY
Nice work. Another possible disaster adverted. Just to be on the safe side, you decide to watch the busy queue for a while but don't want to keep retyping the commands or pressing Escape K. Here's a nice way to watch the queue and let the output refresh on its own. In this example, the queue output refreshes every 5 seconds until the queue has been completely emptied:
# qchk -P pac22_ps -w 5
AIX A-Z: Managing printing on AIX Copyright IBM Corporation 2010. All rights reserved.
Trademarks Page 14 of 17
ibm.com/developerWorks
developerWorks
Conclusions
After reading this article, you should have a better understanding of how to manage print queues and print queue devices in AIX, including how to create them and how to modify or manage them. Knowing more about how the printers and the queues are set up on your system is important. A lot of people don't realize how many settings are in a queue that can be changed easily. You may be able to make someone's day by modifying their printer to suit their needs. Good luck!
AIX A-Z: Managing printing on AIX Copyright IBM Corporation 2010. All rights reserved.
Trademarks Page 15 of 17
developerWorks
ibm.com/developerWorks
Resources
Learn qconfig: Learn more about the qconfig file. mkque: Learn more about the mkque command. mkquedev: Learn more about the mkquedev command. chque: Learn more about the chque command. chquedev: Learn more about the chquedev command. lsque: Learn more about the lsque command. lsquedev: Learn more about the lsquedev command. rmque: Learn more about the rmque command. rmquedev: Learn more about the rmquedev command. AIX and UNIX developerWorks zone: The AIX and UNIX zone provides a wealth of information relating to all aspects of AIX systems administration and expanding your UNIX skills. New to AIX and UNIX? Visit the New to AIX and UNIX page to learn more. Technology bookstore: Browse the technology bookstore for books on this and other technical topics. Discuss developerWorks blogs: Check out our blogs and get involved in the developerWorks community. Follow developerWorks on Twitter. Get involved in the My developerWorks community. Participate in the AIX and UNIX forums: AIX Forum AIX Forum for developers Cluster Systems Management IBM Support Assistant Forum Performance Tools Forum Virtualization Forum More AIX and UNIX Forums
AIX A-Z: Managing printing on AIX Copyright IBM Corporation 2010. All rights reserved.
Trademarks Page 16 of 17
ibm.com/developerWorks
developerWorks
AIX A-Z: Managing printing on AIX Copyright IBM Corporation 2010. All rights reserved.
Trademarks Page 17 of 17