Problem
How do I automatically remove all the print jobs in my print queue?
Solution
Use the following script which can remove all the print jobs on all queues, by default, or you can specify a file which will contain a list of printers in the format:
printer1
printer2
etc:
#
# Variables
#
TMPDIR=/tmp export TMPDIR
PURGE_DIR=/local/lib export PURGE_DIR
PURGE_LIST=$PURGE_DIR/purge_print_list export PURGE_LIST#
# Existence
#
if [ ! -d $PURGE_DIR ]; then
echo "ERROR: $PURGE_DIR does not exist !"
exit 1
fi #
# Process each printer on the queue
#
if [ ! -s $PURGE_LIST ]; then
lpstat -p | awk '{print $2}' > $PURGE_LIST
CLEAR="Y"
else
CLEAR="N"
fi
for i in `cat $PURGE_LIST`
do
echo "Checking $i for prints ... "
while true
do
#
# If the output to the file is greater than zero then
there
# are prints waiting.
#
lpstat -o $i > $TMPDIR/$i.out
if [ -s $TMPDIR/$i.out ]; then
#
# Cancel the print and tidy up
#
cancel $i
rm -f $TMPDIR/$i.out
else
#
# If the file is empty then time to move on
#
break
fi
done
#
# Tidy Up
#
rm -f $TMPDIR/$i.out
done
if [ "${CLEAR}" = "Y" ]; then
rm -f $PURGE_LIST
fiIt is recommended that you install these Network Printing supplements:
SCO UnixWare 2.1.3: SLS ptf4030
UnixWare 7: SLS ptf7438 See also
ta103239, "How do I cancel multiple print jobs on UNIX and XENIX?"