Bulk Remove AIX Print Queues

I have about 50 HP JetDirect print queues on an AIX system that I wanted to remove in a more automated way. The following KSH script is what I came up with to remove the device and queue.

The script attempts to ping the print queue (queues are added by DNS name). If the ping fails, I remove the device using rmqueudev and then remove the queue using rmque.

#!/bin/ksh

for i in $(lpstat | awk '{print $1}')
do

ping -c 1 -w 1 $i >/dev/null 2>&1


if [ $? -ge 1 ];
then
    echo "Purging $i"
    rmquedev -q $i -d hp@$i
    rmque -q $i
fi
done

After running this, I have 6 valid print queues that remain on the AIX system.

Published by

Rich

Just another IT guy.

Leave a Reply

Your email address will not be published. Required fields are marked *