Technical article 103239

How do I cancel multiple print jobs on UNIX and XENIX?

OpenServer 5.0.0OpenServer 5.0.2

Written · Last revised

Problem

When I do "lpstat -o" (or "lpstat -t") I show several print jobs in the queue and I want to cancel all of them. I do not want to cancel them one at a time.

Solution

Use one of the following commands to cancel all print jobs. At the command line type:

1)  lpstat -o | awk '{print $1}' | xargs cancel
2)  lpstat -o | while read a b; do cancel $a; done
If you wish to cancel all jobs for a specific printer
or class, include that name after the -o option.  For
example, if you wish to cancel all jobs for printer
"myprinter", type:
lpstat -omyprinter | awk '{print $1}' | xargs cancel
or   lpstat -omyprinter | while read a b; do cancel $a; done

NOTE: The above commands demonstrate two different shell script styles of doing the same thing.

From the Xinuos technical article database, record 103239. Reproduced with permission. The original is at www.sco.com/ta/103239, which is reachable but blocked from search engines. Xinuos marks this article against a retired product line. That refers to the product’s lifecycle, not to whether the advice still works — plenty of it still applies to running systems.

Next step

Need this fixed rather than explained?

Tell us the release, what the system runs and what it is doing. We will reply by email with what we would do next.

  • You deal with the people who do the work
  • No obligation, and no upgrade required before we will help
  • We tell you plainly if something is not worth doing

Send an enquiry

We reply by email. If a server is down, say so in the first line. You can also write to help@scoexpert.com.