Operating System - HP-UX
1819929 Members
3149 Online
109607 Solutions
New Discussion юеВ

script to reset print spooler

 
James Wardlaw_1
New Member

script to reset print spooler

I capture text on a pc from my HP-UX 10.2 server. for some reason the spooler hangs and to get it going again i have to manually start and stop the print spooler almost daily. ie after a weeks vacation i have 8,000 small print requests in the que. If i had a script that would reset the spooler daily this wouldnt hang up my spooler.

Thanks,

James
7 REPLIES 7
harry d brown jr
Honored Contributor

Re: script to reset print spooler

Start your script like this:

#!/usr/bin/ksh
#


then add your commands to it, then tell cron to run it once a day.


live free or die
harry
Live Free or Die
pap
Respected Contributor

Re: script to reset print spooler

Hi you can do as below

/sbin/init.d/lp stop
/sbin/init.d/lp start

That will restart the spooler

put the script in cronjob.

-pap

"Winners don't do different things , they do things differently"
harry d brown jr
Honored Contributor

Re: script to reset print spooler


The real problem to SOLVE is WHY is it hanging the spool queue? Solve that problem and you don't need to "bounce" the spooler.

Can any of this be answered?
* What are you "capturing"?
* how are you doing it (capturing)?
* how are you sending it to the print queue?
* is the printer hung?
* are there any "control" or "escape sequences" in the file being sent to the printer?

live free or die
harry
Live Free or Die
MANOJ SRIVASTAVA
Honored Contributor

Re: script to reset print spooler

Hi James

First the reason as to why it happenes to be found out . Incase still you want the script
add the following to the cron of the root

0 1 * * * /usr/local/adm/lprestart

and under the directory /usr/local/adm

create and executable script

#!bin/sh
/usr/sbin/lpshut
sleep 30
/usr/sbin/lpsched

please make sure that the permissions are set to excutable

Manoj Srivastava
Ross Martin
Trusted Contributor

Re: script to reset print spooler

You may want to check to see if you have the latest lpspool cumulative patch PHCO_25109 for 10.20. (No reboot required and no dependencies).

It deals with spooler hangs and such -- maybe that is what you are encountering and it can be resolved with a patch.

Hope that helps.

Ross Martin
HP Response Center

Bill Hassell
Honored Contributor

Re: script to reset print spooler

It's not normal for the spooler to hang. Have you kept your system up to date on patches? Not just lp spooler but ARPA networking and LVM and shells, etc?

The process to shutdown the spooler and restart it is simply:

# lpshut
# lpsched

However, you might want to call the standard HP-UX start/stop script as in:

# /sbin/init.d/lp stop
# /sbin/init.d/lp start

Just put this into a script such as:

#!/usr/bin/sh
/sbin/init.d/lp stop
/sbin/init.d/lp start


But you might also check for hung instances of lp processes:

# ps -u lp

So the script becomes:

#!/usr/bin/sh
/sbin/init.d/lp stop
sleep 2

PID4LP=$(/usr/bin/ps -u blh | awk '$1 !~ /PID/ {print $1}')
if [ $PID4LP#} -ne 0 ]
then
for PIDLP in $PID4LP
do
/usr/bin/kill -9 $PIDLP
done
/sbin/init.d/lp start


Put the above into a script, test it to see that it really works OK (hint, use sh -x ro run the script) and then add it to cron.


Bill Hassell, sysadmin
Steve Steel
Honored Contributor

Re: script to reset print spooler

Hi


All good advice especially for the patches.

One more.


Check the value of nproc and maxuprc.

If maxuprc is low the spooler can hang.


Steve Steel
If you want truly to understand something, try to change it. (Kurt Lewin)