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!

How To Clear Print queue???? 2

Status
Not open for further replies.

WB786

MIS
Mar 14, 2002
610
We have an IBM AIX 5.2 server and I am not a UNIX expert but am learning. I need to know if there is a script that can be written to clear the print queue on a nightly basis automatically.

Thanks,

:)WB
 
I assume these are prints which no-one wants? In which case why are they being sent to the printer at all?
 
Well we had a problem with one our store shop printer hanging up and which caused the print queue to build up. And sometimes I don't have time to go out to the site and fix the printer so for the last two times I had to clear the print queue manually which had over 1000 print jobs stuck. The store also prints a copy of the same report in the front as well. The shop guys use the check-in printout to maintain the equipment - these guys at the store don't call me right away when there is a problem, they have a bad of habit of just dealing with the problem. So, I figured if I could just setup a routine to automatically to clear the print queue on a night basis until I can get out to the site to fix the printer.

Thanks,

:)WB
 
One more thing - Is there a cancel ALL so I don't have to type in the individual print queue - there are over 20 printers in the print queue.

Thanks,

:)WB
 
WB, thanks for the explanation. You could write a script to read all the printer queue names from a file and then issue a cancel against each using a script. Post back if you need help with that.
 
Something like:

while read queue
do
cancel $queue
done < list

Where list.txt contains you list of printers.
 
Oh for an edit option!

done < list

should of course be

done < list.txt

Apologies!
 
Would it be possible to write a script and just list all the printers in it instead of calling an external file and if so then how would the script would look like from start to finish. As you can see I am just getting to know UNIX scripting.

Thanks,

:)WB
 
If you want to cancel all print jobs on a print queue then:

qcan -P<Printer>
 
It would. But wouldn't a simple list of the printers be easier to edit than an individual entry in a script in terms of adding and deleting printers as they are brought into/taken out of use? Let us know if you would prefer your option and I'm sure someone will help further.
 
Ken you got a point there. With your option one doesn't need to modify the main script file and if I ever left the company someone else can easily just update the printer names file and that would be it.

Ok with that in mind then what would the whole scipt would look like?

Thanks,




:)WB
 
WB, good of you to be so magnanimous to your successors - an unusual quality as any sysdamin would tell you!!

You need to put the following into a script (say cancellall.sh) using vi or another editor of your choice:

while read queue
do
cancel $queue
done < list.txt


and create your list.txt with the names of the queues, each on a separate line and exactly as they are if using the cancel separately.

Make cancellall.sh executable (chmod 755 cancellall.sh for example) and run it using ./cancellall.sh from the command line.

If you wish to run it nightly as originally stipulated, you'll need to set up a cron job in the format (example):

00 03 * * * /path/to/cancellall.sh

to run the script at 3:00 am every day.

Hope this helps.
 
You could do it this way

stopsrc -s qdaemon
cd /var/spool/lpd/qdir
rm *
cd /var/spool/lpd/stat
rm *
cd /var/spool/qdaemon
rm *
cd /var/spool/lpd
rm *
startsrc -s qdaemon

You may have to re-enable your queues

enable <quename>

Mike

"A foolproof method for sculpting an elephant: first, get a huge block of marble, then you chip away everything that doesn't look like an elephant."

 
MRN and Ken,

Is one method better than the other. MRN example sure looks easier to do.

Thanks,

:)WB
 
I would suggest you test both methods. I would suspect my offering might be faster, it's also the recommended IBM method (But that doesn't mean much!!!).


Mike

"A foolproof method for sculpting an elephant: first, get a huge block of marble, then you chip away everything that doesn't look like an elephant."

 
It might well be, but you won't get much simpler than a four-line script. Anyway, your call I guess.
 
THANK YOU BOTH FOR SOME GREAT INSIGHT! I WILL TRY THEM BOTH.

THANKS AGAIN!!!

:)WB
 
Thanks for the star! As Mike says, it would be useful if you could test both and report back here with your conclusions if possible. Good luck.
 
Yes Thanks for the Star.

One point I should have made. Backup before you try.

Mike

"A foolproof method for sculpting an elephant: first, get a huge block of marble, then you chip away everything that doesn't look like an elephant."

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top