If you have sent a job to the printer that you want to cancel, you can remove it from the print queue using either the lprm or cancel commands, depending on whether you have a System Vor BSD-derived version of UNIX.
On a BSD-derived system, use the lprm command with the printer job number. For example, suppose a mythical user named Lois uses the lpq command and discovers that she sent a job twice:
% lpq emu is ready and printing Rank Owner Job Files Total Size active bob 420 RELNOTES.ps 138331 bytes 1st bob 421 standard input 13284 bytes 2nd lois 422 standard input 1928 bytes 3rd lois 423 standard input 1928 bytes
Rather than waste paper, she chooses to remove one of the identical print jobs. She uses the job number reported by lpq and applies that to the lprm command:
% lprm 422 dfA422ruby dequeued cfA422ruby dequeued
If she had decided to delete both print jobs on her default printer , she could omit the job number:
% lprm dfA422ruby dequeued cfA422ruby dequeued cfA423ruby dequeued cfA423ruby dequeued
Without arguments, lprm removes all print jobs belonging to you on the target printer.
Notice that you cannot remove someone else’s job. So even if Lois wanted to, there’s no way for her to remove Bob’s jobs and put hers at the top without the administrator’s assistance.
On a System V-based system, use the cancel command. First use lpstat to find out the job number:
% lpstat ibis-007 lois 1443 Feb 08 18:22 on ibis
Then use the job number with the cancel command.
% cancel ibis-007 request "ibis-007" cancelled
To cancel all your jobs, use cancel -u with your user name:
% cancel -u lois request "ibis-8" cancelled request "dodo-10" cencelled