Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Enable multiple printq at once 1

Status
Not open for further replies.

sraj142

Technical User
Oct 25, 2006
49
IN
Hi All,
My AIX Box having approx 2000 Print Queue. Often some queues goes down & I have to enable them one by one ! I can check the status by 'lpstat -a<queue name>'.
Now I need to creat a 'C' program which will be running continuously & enable those print queues which is/are disable. I will creat a daemon & assign the program than.

Can anybody help me please ?

Regards - Sraj
 
Hi Sraj,

Ok I have exactly what you want (but in ksh instead)! Here is the script that we use to enable our print queues:

Code:
#!/bin/ksh
ddd=`date`
qdstat=`lssrc -s qdaemon`
echo "" >>/tmp/qd.log
echo "Time $ddd " >> /tmp/qd.log
echo $qdstat >> /tmp/qd.log
#
startsrc -s qdaemon
#
sleep 30
# Now enable any down print queues
#

/usr/bin/lsallq > printer_up.tmp
while read prtid junk
do
  sleep 5
  enable $prtid
done < printer_up.tmp

This script is crontabed in our server with this line:

Code:
0,15,30,45 * * * * /scripts/printer_up.scr 1>/dev/null 2>/dev/null

I hope this is helpful enough!

Regards,
Khalid
 
Hi Khalid,
Thanks for the help. But it seems that it is enabling all the print queues, instead of the down one.
Can it be possible to enable those queues only which are down ?

Regards - Sraj
 
Hi Sraj,

It doesn't do any harm to enable all! In fact it will not enable the ones that are already enabled! It will bypass them. But for providing a neat script, I managed to come up with this:

Code:
#!/bin/ksh
ddd=`date`
qdstat=`lssrc -s qdaemon`
echo "" >>/tmp/qd.log
echo "Time $ddd " >> /tmp/qd.log
echo $qdstat >> /tmp/qd.log
#
startsrc -s qdaemon
#
sleep 30
# Now enable any down print queues
#

/usr/bin/lsallq > printer_up.tmp
while read prtid junk
do
  sleep 5
  qtest=$(qchk -P$prtid | grep DOWN)
  if [[ $qtest != "" ]]
  then
    enable $prtid
  fi
done < printer_up.tmp

This should do the job! Only queues that are down will be enabled!

Regards,
Khalid
 
...But the script might "hang" for a long time for remote queues of which the remote server is (temporarily) unreachable; I would not run this script from cron every 5 minutes.

Just run the first example: enable all queues, even the ones that aren't down...

And if you want to bypass some queues, filter them out like so:

Code:
BYPASS='^queue1$|^queue2$|^queue13$'

/usr/bin/lsallq |\
 grep -E -v "${BYPASS}"|\
 while read prtque
 do
  enable $prtque
 done


HTH,

p5wizard
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top