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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

need script to restart print que from cron 1

Status
Not open for further replies.

lblauen

Technical User
Aug 13, 2002
69
I have 3 or 4 print queues that like to die at night. I have to restart them every morning. I need a quick script to test lpstat | grep -v READY and list the queues that are down and issue the command enable DOCK264 or what ever the queue name is. I would like to have cron run the script every hour and reset print queues as needed. Can anyone help please.

Tnaks Lloyd.
 
Can you paste...
- an example line from lpstat
- the command you want to issue based on a value in that line.

 
root@sv820b / > lpstat -W | grep -v READY
Queue Dev Status Job DOCK234 TCPrint@DOCK23 DOWN
QUEUED 226327 /prod/cms/dm/repor fessler
QUEUED 226328 /prod/cms/dm/repor fessler
QUEUED 221721 /prod/cms/dm/repor takacs

DOCK264 TCPrint@DOCK26 DOWN
QUEUED 226326 /prod/cms/dm/repor fessler

are the queues and I would like to issue the command enable DOCK264 DOCK234

Thanks Lloyd
 
Try this awk command
Code:
lpstat -W | grep -v READY | awk '/^DOCK/ && $NF == "DOWN" { system("enable " $1) }'
 
This works great for the DOCK queues but there are others. Can this be more generic in the queue name and still work?

example
TRF_LASER_1 hp@trfc_hp4 READY
EXP_LASER hp@exp_hp5n READY
FOODS_LASER_1 hp@foods_hp8k READY
GENMDSE_LASER hp@genmdse_hp8 READY
 
Well if a line like this
QUEUED 226328 /prod/cms/dm/repor fessler

never ends in the word "DOWN", then simply remove

/^DOCK/ &&

from the test

Code:
lpstat -W | grep -v READY | awk '$NF == "DOWN" { system("enable " $1) }'
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top