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

auto enable down print queues?? 1

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Anyone know of such a script that will check for down print queues and automatically enable them?? This way I don't always have to manually enable.

Thanks
Anthony
 
Try this. I put this on the crontab to run every hour and the results e-mailed. I need to set it up so it only e-mails me when queues were actully down but you could easily remove this step if you didn't want it to send you e-mail.


#!/bin/ksh
#
#
DATE=`date`
THISHOST=`uname -n`
lpstat|grep DOWN|awk '{print $1}' >> /tmp/lpstat.$$
for i in `cat /tmp/lpstat.$$`
do
enable $i
done
echo "The date/time is $DATE." >> /tmp/lpstat.$$
echo "\nThese queues were DOWN and have been enabled." >> /tmp/lpstat.$$
mail -s &quot;$THISHOST Printer Status&quot; your@email.com < /tmp/lpstat.$$
sleep 10
rm -f /tmp/lpstat.$$
 

Nice script.....really like it...

If you want to only email when you have data do the following

#!/bin/ksh
#
#
THISHOST=`uname -n`
lpstat|grep DOWN|awk '{print $1}' >> /tmp/lpstatdown.log

if test -s /tmp/lpstatdown.log
then
for i in `cat /tmp/lpstatdown.log`
do
enable $i
done

echo &quot;The date/time is `date` &quot; >> /tmp/lpstatdown.log
echo &quot;\nThese queues were DOWN and have been enabled.&quot; >> /tmp/lpstatdown.log
mail -s &quot;$THISHOST Printer Status&quot; root@localhost < /tmp/lpstatdown.log
sleep 10
rm -f /tmp/lpstatdown.log

fi
 
Thanks so much, I'm gonna give that a shot!
I appreciate the help!!
 
That is what I needed. Now the inbox is a little less cluttered. Thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top