auto clear stuck print jobs

jbosma
New Contributor II

Does anyone have a good script that will automatically clear any stuck print job after a period of time?

3 REPLIES 3

cbrewer
Valued Contributor II

I run the following on logout. This way the print queue is cleared for the next user.

cancel -a; cupsenable `lpstat -p | grep 'disabled' | awk '{print $2}'`

ezemke
New Contributor III

I run the following on logout. It cancels any jobs that may be pending and then ensures the printer is not paused.
Replace PRINTER## with then name of your printers

cancel -a; cupsenable PRINTER#1; cupsenable PRINTER#2; cupsenable #3; cupsenable PRINTER#4

winningham_2
Contributor

I run the below, after installing printers, to set the printer to "abort the job" on error rather than pausing printing. JAMF's capture method doesn't seem to pick this up from the printers.conf if one was to set it manually. Otherwise, I do something similar to @cbrewer

#!/bin/sh -v
exec 2>&1

####Obtain the printers as an array
PRINTERS="`lpstat -v | awk '{print $3}' | sed 's/://'`"


####Loops through the printers and applies the error policy to them
for P in ${PRINTERS[@]}
do  

lpadmin -p $P -o printer-error-policy=abort-job

done