next up previous contents
Next: Configuration issues Up: RedHat 9 Lab Machines Previous: /usr/local/dunn358printer.xml   Contents

/usr/local/clear-queues

IMPORTANT: This script is run from a crontab on Minotaur, the main linux fileserver. NOT run on individual machines, although, I guess it could be?

clear-queues script is created for clearing.... print queues. Couldn't have guessed that one in a million years. This script is for all those times when a stuck queue ruins the day, we all hate that, i'm sure. More is explained in the script header itself, it is run from a crontab entry.

#!/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



2003-08-28