1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> 2 3<html> 4 <head> 5 <meta name="generator" content="HTML Tidy, see www.w3.org"> 6 <title>Controlling the Print Queue</title> 7 <meta name="GENERATOR" content= 8 "Modular DocBook HTML Stylesheet Version 1.7"> 9 <link rel="HOME" title=" LPRng Reference Manual" href= 10 "index.htm"> 11 <link rel="UP" title="Print Spooling Tutorial " href= 12 "tutorial.htm"> 13 <link rel="PREVIOUS" title="Selecting the Print Queue" href= 14 "selectingprintqueue.htm"> 15 <link rel="NEXT" title="Job Removal" href="jobremoval.htm"> 16 </head> 17 18 <body class="SECT1" bgcolor="#FFFFFF" text="#000000" link= 19 "#0000FF" vlink="#840084" alink="#0000FF"> 20 <div class="NAVHEADER"> 21 <table summary="Header navigation table" width="100%" border= 22 "0" cellpadding="0" cellspacing="0"> 23 <tr> 24 <th colspan="3" align="center">LPRng Reference Manual: 5 25 Sep 2003 (For LPRng-3.8.22)</th> 26 </tr> 27 28 <tr> 29 <td width="10%" align="left" valign="bottom"><a href= 30 "selectingprintqueue.htm" accesskey="P">Prev</a></td> 31 32 <td width="80%" align="center" valign="bottom">Chapter 4. 33 Print Spooling Tutorial</td> 34 35 <td width="10%" align="right" valign="bottom"><a href= 36 "jobremoval.htm" accesskey="N">Next</a></td> 37 </tr> 38 </table> 39 <hr align="LEFT" width="100%"> 40 </div> 41 42 <div class="SECT1"> 43 <h1 class="SECT1"><a name="CONTROLLINGPRINTQUEUE">4.7. 44 Controlling the Print Queue</a></h1> 45 46 <p>The <b class="APPLICATION">lpc</b> command is used to 47 examine and control the print server operation. The <tt 48 class="COMMAND">lpc status</tt> command displays the 49 administrative status of a print queue. The <b class= 50 "APPLICATION">lpd</b> program caches status and job 51 information in order to improve performance. The <tt class= 52 "COMMAND">lpc flush</tt> command will flush the cached 53 information and cause the server to regenerate it. The <tt 54 class="COMMAND">lpc enable</tt> and <tt class="COMMAND">lpc 55 disable</tt> commands enable or disable spooling to the print 56 queue, and the <tt class="COMMAND">lpc stop</tt> and <tt 57 class="COMMAND">lpc start</tt> commands stop and start 58 printing (or transfers) of jobs in the print queue.</p> 59 60 <p>Let's look at the status displayed when we use these 61 commands:</p> 62 63 <div class="INFORMALEXAMPLE"> 64 <a name="AEN2003"></a> 65<pre class="SCREEN"> 66 <samp class="PROMPT">h4: {120} %</samp> <kbd class= 67"USERINPUT">lpc status</kbd> 68 Printer Printing Spooling Jobs Server Subserver Redirect Status/(Debug) 69 lp@h4 enabled enabled 0 none none 70 <samp class="PROMPT">h4: {121} %</samp> <kbd class= 71"USERINPUT">lpc status all</kbd> 72 Printer Printing Spooling Jobs Server Subserver Redirect Status/(Debug) 73 lp@h4 enabled enabled 0 none none 74 lp2@h4 enabled enabled 0 none none 75 <samp class="PROMPT">h4: {122} %</samp> <kbd class= 76"USERINPUT">lpc</kbd> 77 lpc>status 78 Printer Printing Spooling Jobs Server Subserver Redirect Status/(Debug) 79 lp@h4 enabled enabled 0 none none 80 lpc>status all 81 Printer Printing Spooling Jobs Server Subserver Redirect Status/(Debug) 82 lp@h4 enabled enabled 0 none none 83 lp2@h4 enabled enabled 0 none none 84 lpc>quit 85</pre> 86 </div> 87 <br> 88 <br> 89 90 <p>The <b class="APPLICATION">lpc</b> command can be used in 91 command line or interactive mode as shown above. When used 92 with no parameters it will run in interactive mode, reading 93 one or more commands from its standard input (<acronym class= 94 "ACRONYM">STDIN</acronym>). The <tt class="COMMAND">lpc 95 status</tt> command shows the administrative status of the 96 select print queue. The <var class="LITERAL">all</var> queue 97 name selects all print queues for display. As shown in the 98 above example, both print queues have printing and spooling 99 enabled and there are no jobs in the print queue. The <span 100 class="emphasis"><i class="EMPHASIS">Server</i></span> and 101 <span class="emphasis"><i class= 102 "EMPHASIS">Subserver</i></span> information shows if there is 103 a process which is printing jobs, and its helper process that 104 does the actual communication with the printer.</p> 105 106 <p>It might be puzzling at first why <b class= 107 "APPLICATION">LPRng</b> uses two processes for this 108 operation, but the reason is very simple. Many operating 109 system implementations have <span class="emphasis"><i class= 110 "EMPHASIS">memory leaks</i></span> that cause the actual 111 process size to grow as it runs. This is especially true if a 112 large number of databases such as the password, Domain Name 113 Server, or other system database is consulted frequently with 114 different queries. Since this is usually done quite a lot by 115 the process which deals with the actual printing, the 116 printing process would soon grow very large and then die when 117 it could no longer obtain more memory. The <span class= 118 "emphasis"><i class="EMPHASIS">Server</i></span> process will 119 fork or create a child process <span class="emphasis"><i 120 class="EMPHASIS">Subserver</i></span> process that is 121 responsible for the printing of a single job. When the job 122 printing has been completed, the <span class="emphasis"><i 123 class="EMPHASIS">Subserver</i></span> process will exit and 124 the <span class="emphasis"><i class= 125 "EMPHASIS">Server</i></span> process will then create another 126 child until there are no more jobs to be printed. The <span 127 class="emphasis"><i class="EMPHASIS">Redirect</i></span> and 128 <span class="emphasis"><i class="EMPHASIS">Debug</i></span> 129 fields will be discussed in later sections.</p> 130 131 <p>Now let's use the basic spool queue control commands:</p> 132 133 <div class="INFORMALEXAMPLE"> 134 <a name="AEN2028"></a> 135<pre class="SCREEN"> 136 <samp class="PROMPT">h4: {123} %</samp> <kbd class= 137"USERINPUT">lpc disable</kbd> 138 Printer: lp@h4 139 lp@h4.private: disabled 140 <samp class="PROMPT">h4: {124} %</samp> <kbd class= 141"USERINPUT">lpq</kbd> 142 Printer: lp@h4 (spooling disabled) 143 Queue: no printable jobs in queue 144 <samp class="PROMPT">h4: {125} %</samp> <kbd class= 145"USERINPUT">lpc enable</kbd> 146 Printer: lp@h4 147 lp@h4.private: enabled 148 <samp class="PROMPT">h4: {126} %</samp> <kbd class= 149"USERINPUT">lpq</kbd> 150 Printer: lp@h4 151 Queue: no printable jobs in queue 152 <samp class="PROMPT">h4: {127} %</samp> <kbd class= 153"USERINPUT">lpc stop</kbd> 154 Printer: lp@h4 155 lp@h4.private: stopped 156 <samp class="PROMPT">h4: {128} %</samp> <kbd class= 157"USERINPUT">lpq</kbd> 158 Printer: lp@h4 (printing disabled) 159 Queue: no printable jobs in queue 160 <samp class="PROMPT">h4: {129} %</samp> <kbd class= 161"USERINPUT">lpc start</kbd> 162 Printer: lp@h4 163 lp@h4.private: started 164 <samp class="PROMPT">h4: {130} %</samp> <kbd class= 165"USERINPUT">lpq</kbd> 166 Printer: lp@h4 167 Queue: no printable jobs in queue 168</pre> 169 </div> 170 <br> 171 <br> 172 173 <p>As we can see, the <b class="APPLICATION">lpc</b> command 174 also reports on the status of the print queue. Let's see what 175 happens when we print to a stopped queue:</p> 176 177 <div class="INFORMALEXAMPLE"> 178 <a name="AEN2048"></a> 179<pre class="SCREEN"> 180 <samp class="PROMPT">h4: {131} %</samp> <kbd class= 181"USERINPUT">lpc stop</kbd> 182 Printer: lp@h4 183 lp@h4.private: stopped 184 <samp class="PROMPT">h4: {132} %</samp> <kbd class= 185"USERINPUT">lpr /tmp/hi</kbd> 186 <samp class="PROMPT">h4: {133} %</samp> <kbd class= 187"USERINPUT">lpr /tmp/hi /tmp/there</kbd> 188 <samp class="PROMPT">h4: {134} %</samp> <kbd class= 189"USERINPUT">lpq</kbd> 190 Printer: lp@h4 (printing disabled) 191 Queue: 2 printable jobs 192 Server: no server active 193 Rank Owner/ID Class Job Files Size Time 194 1 papowell@h4+17920 A 17920 /tmp/hi 3 18:14:22 195 2 papowell@h4+17922 A 17922 /tmp/hi,/tmp/there 9 18:14:30 196 <samp class="PROMPT">h4: {135} %</samp> <kbd class= 197"USERINPUT">lpc status</kbd> 198 Printer Printing Spooling Jobs Server Subserver Redirect Status/(Debug) 199 lp@h4 disabled enabled 2 none none 200</pre> 201 </div> 202 <br> 203 <br> 204 205 <p>The <b class="APPLICATION">lpc</b> status shows that we 206 have two jobs spooled. The <span class="emphasis"><i class= 207 "EMPHASIS">Rank</i></span> field shows the order, the <tt 208 class="FILENAME">Owner/ID</tt> shows the unique job ID that 209 is assigned to the job and the <span class="emphasis"><i 210 class="EMPHASIS">Class</i></span> field is the job class 211 (this may be changed with the <tt class="COMMAND">lpr -C 212 class</tt> option). The <span class="emphasis"><i class= 213 "EMPHASIS">Job</i></span> field shows the <span class= 214 "emphasis"><i class="EMPHASIS">job number</i></span> assigned 215 to this job in this particular spool queue. While the 216 <acronym class="ACRONYM">ID</acronym> value never changes as 217 a job moves through the <b class="APPLICATION">LPRng</b> 218 system, the <span class="emphasis"><i class="EMPHASIS">job 219 number</i></span> is specific to a particular spool queue and 220 may change if a job is <span class="emphasis"><i class= 221 "EMPHASIS">forwarded</i></span> to another spool queue that 222 has a job with the same job number. The <span class= 223 "emphasis"><i class="EMPHASIS">Size</i></span> field is the 224 total number of printable bytes in the job, and the <span 225 class="emphasis"><i class="EMPHASIS">Time</i></span> field 226 shows the timestamp associated with the job.</p> 227 228 <p>Now let's start the print queue and watch what 229 happens.</p> 230 231 <div class="INFORMALEXAMPLE"> 232 <a name="AEN2075"></a> 233<pre class="SCREEN"> 234 <samp class="PROMPT">h4: {136} %</samp> <kbd class= 235"USERINPUT">lpc start</kbd> 236 Printer: lp@h4 237 lp@h4.private: started 238 <samp class="PROMPT">h4: {137} %</samp> <kbd class= 239"USERINPUT">lpq</kbd> 240 Printer: lp@h4 241 Queue: 2 printable jobs 242 Server: pid 17928 active 243 Unspooler: pid 17929 active 244 Status: opening device '/tmp/lp' at 18:14:43.921 245 Rank Owner/ID Class Job Files Size Time 246 active papowell@h4+17920 A 17920 /tmp/hi 3 18:14:22 247 2 papowell@h4+17922 A 17922 /tmp/hi,/tmp/there 9 18:14:30 248 <samp class="PROMPT">h4: {138} %</samp> <kbd class= 249"USERINPUT">lpq -ll</kbd> 250 Printer: lp@h4 251 Queue: 2 printable jobs 252 Server: pid 17928 active 253 Unspooler: pid 17929 active 254 Status: printing job 'papowell@h4+17920' at 18:14:43.921 255 Status: no banner at 18:14:43.921 256 Status: printing data file 'dfA017920h4.private', size 57 at 18:14:43.922 257 Rank Owner/ID Class Job Files Size Time 258 active papowell@h4+17920 A 17920 /tmp/hi 3 18:14:22 259 2 papowell@h4+17922 A 17922 /tmp/hi,/tmp/there 9 18:14:30 260</pre> 261 </div> 262 <br> 263 <br> 264 265 <p>The <span class="emphasis"><i class= 266 "EMPHASIS">Rank</i></span> value of the first job has been 267 changed to <var class="LITERAL">active</var> and there is new 268 <span class="emphasis"><i class="EMPHASIS">Status</i></span> 269 information. If we use <tt class="COMMAND">lpq -ll</tt> we 270 can see the times that the various print operations are 271 carried out, and details of their success or failure.</p> 272 273 <p>We can also use the <b class="APPLICATION">lpc</b> command 274 to see the status of a particular job. We can select jobs by 275 the user name, the ID, or the job number. For example:</p> 276 277 <div class="INFORMALEXAMPLE"> 278 <a name="AEN2090"></a> 279<pre class="SCREEN"> 280 <samp class="PROMPT">h4: {139} %</samp> <kbd class= 281"USERINPUT">lpc stop</kbd> 282 Printer: lp@h4 283 lp@h4.private: stopped 284 <samp class="PROMPT">h4: {140} %</samp> <kbd class= 285"USERINPUT">echo hi |lpr</kbd> 286 <samp class="PROMPT">h4: {141} %</samp> <kbd class= 287"USERINPUT">echo there | lpr</kbd> 288 <samp class="PROMPT">h4: {142} %</samp> <kbd class= 289"USERINPUT">echo test |lpr</kbd> 290 <samp class="PROMPT">h4: {143} %</samp> <kbd class= 291"USERINPUT">lpq</kbd> 292 Printer: lp@h4 (printing disabled) 293 Queue: 3 printable jobs 294 Server: no server active 295 Status: job 'papowell@h4+17922' removed at 18:15:13.981 296 Rank Owner/ID Class Job Files Size Time 297 1 papowell@h4+17959 A 17959 (stdin) 3 18:23:24 298 2 papowell@h4+17962 A 17962 (stdin) 6 18:23:30 299 3 papowell@h4+17970 A 17970 (stdin) 5 18:23:35 300 <samp class="PROMPT">h4: {144} %</samp> <kbd class= 301"USERINPUT">lpq 17970</kbd> 302 Printer: lp@h4 (printing disabled) 303 Queue: 3 printable jobs 304 Server: no server active 305 Status: job 'papowell@h4+17922' removed at 18:15:13.981 306 Rank Owner/ID Class Job Files Size Time 307 3 papowell@h4+17970 A 17970 (stdin) 5 18:23:35 308 <samp class="PROMPT">h4: {145} %</samp> <kbd class= 309"USERINPUT">lpq papowell</kbd> 310 Printer: lp@h4 (printing disabled) 311 Queue: 3 printable jobs 312 Server: no server active 313 Status: job 'papowell@h4+17922' removed at 18:15:13.981 314 Rank Owner/ID Class Job Files Size Time 315 1 papowell@h4+17959 A 17959 (stdin) 3 18:23:24 316 2 papowell@h4+17962 A 17962 (stdin) 6 18:23:30 317 3 papowell@h4+17970 A 17970 (stdin) 5 18:23:35 318 <samp class="PROMPT">h4: {146} %</samp> <kbd class= 319"USERINPUT">lpq -s 17970</kbd> 320 lp@h4 1 jobs 321 <samp class="PROMPT">h4: {147} %</samp> <kbd class= 322"USERINPUT">lpq -s papowell</kbd> 323 lp@h4 3 jobs 324 <samp class="PROMPT">h4: {148} %</samp> <kbd class= 325"USERINPUT">lpq -s nobody</kbd> 326 lp@h4 0 jobs 327</pre> 328 </div> 329 <br> 330 <br> 331 332 <p>We use <tt class="COMMAND">lpq -Pqueuename</tt> to select 333 a specific print queue and <tt class="COMMAND">lpq -a</tt> or 334 <tt class="COMMAND">lpq -Pall</tt> to select all queues:</p> 335 336 <div class="INFORMALEXAMPLE"> 337 <a name="AEN2116"></a> 338<pre class="SCREEN"> 339 <samp class="PROMPT">h4: {149} %</samp> <kbd class= 340"USERINPUT">lpc -a stop</kbd> 341 Printer: lp@h4 342 lp@h4.private: stopped 343 Printer: lp2@h4 344 lp2@h4.private: stopped 345 <samp class="PROMPT">h4: {150} %</samp> <kbd class= 346"USERINPUT">lpc -Pall start</kbd> 347 Printer: lp@h4 348 lp@h4.private: started 349 Printer: lp2@h4 350 lp2@h4.private: started 351</pre> 352 </div> 353 <br> 354 <br> 355 356 <p>You can use the <b class="APPLICATION">lpc</b> command in 357 <span class="emphasis"><i class= 358 "EMPHASIS">interactive</i></span> mode:</p> 359 360 <div class="INFORMALEXAMPLE"> 361 <a name="AEN2125"></a> 362<pre class="SCREEN"> 363 <samp class="PROMPT">h4: {151} %</samp> <kbd class= 364"USERINPUT">lpc</kbd> 365 lpc>status 366 Printer Printing Spooling Jobs Server Subserver Redirect Status/(Debug) 367 lp@h4 enabled enabled 3 17990 17993 368 lpc>status all 369 Printer Printing Spooling Jobs Server Subserver Redirect Status/(Debug) 370 lp@h4 enabled enabled 3 17990 17993 371 lp2@h4 enabled enabled 3 none none 372 lpc>stop lp 373 Printer: lp@h4 374 lp@h4.private: stopped 375 lpc>start lp 376 Printer: lp@h4 377 lp@h4.private: started 378 lpc>quit 379</pre> 380 </div> 381 <br> 382 <br> 383 384 <p>The <tt class="COMMAND">lpc topq</tt> command can be used 385 to put a job (or jobs) at the head of the spool queue. This 386 command is very useful when some job requires priority 387 service. You can select the job by using the job number or 388 the job ID.</p> 389 390 <div class="INFORMALEXAMPLE"> 391 <a name="AEN2131"></a> 392<pre class="SCREEN"> 393 <samp class="PROMPT">h4: {152} %</samp> <kbd class= 394"USERINPUT">lpc topq lp 17970</kbd> 395 Printer: lp@h4 396 lp: selected 'papowell@h4+17970' 397 lp@h4.private: started 398 <samp class="PROMPT">h4: {153} %</samp> <kbd class= 399"USERINPUT">lpq</kbd> 400 Printer: lp@h4 401 Queue: 3 printable jobs 402 Server: pid 17999 active 403 Rank Owner/ID Class Job Files Size Time 404 active papowell@h4+17970 A 17970 (stdin) 5 18:23:35 405 1 papowell@h4+17959 A 17959 (stdin) 3 18:23:24 406 2 papowell@h4+17962 A 17962 (stdin) 6 18:23:30 407</pre> 408 </div> 409 <br> 410 <br> 411 </div> 412 413 <div class="NAVFOOTER"> 414 <hr align="LEFT" width="100%"> 415 416 <table summary="Footer navigation table" width="100%" border= 417 "0" cellpadding="0" cellspacing="0"> 418 <tr> 419 <td width="33%" align="left" valign="top"><a href= 420 "selectingprintqueue.htm" accesskey="P">Prev</a></td> 421 422 <td width="34%" align="center" valign="top"><a href= 423 "index.htm" accesskey="H">Home</a></td> 424 425 <td width="33%" align="right" valign="top"><a href= 426 "jobremoval.htm" accesskey="N">Next</a></td> 427 </tr> 428 429 <tr> 430 <td width="33%" align="left" valign="top">Selecting the 431 Print Queue</td> 432 433 <td width="34%" align="center" valign="top"><a href= 434 "tutorial.htm" accesskey="U">Up</a></td> 435 436 <td width="33%" align="right" valign="top">Job 437 Removal</td> 438 </tr> 439 </table> 440 </div> 441 </body> 442</html> 443 444