#!/bin/bash # # clear-queues script, for the CIS labs (or elsewhere?) # # should clear any queues that have the following properties: # - # - There is nobody logged in on the computer - when this happens, # clear the entire queue doing a `lprm -a all` # - The print job had some sort of ERROR # - The print job is stalled # - The print job is done, but just sitting there in the queue like # it owned the place. # # # this script runs from a crontab like so: # 0,10,20,30,40,50 * * * * /root/lab-command /usr/local/clear-queues # # where lab-command is an ssh script that takes one command-line argument, # in this case 'clear-queues' the script (this one) # # # Eric Thern # September 15, 2002 # if [ "`finger`" = "No one logged on." ] then lprm -a all echo "removing all queues on computer `hostname`" else SE_OCUPA=LA_COMPUTADORA fi for i in `lpq | egrep '(ERROR|stalled|done)' | awk '{print $4}'`; do lprm $i; done