AIXStopRestartPrinterQueues

== How to stop/restart printer queues ==

This is very quick, but should cover all the bases:

==== 1. Displaying printer queues status. ====

Use the {{{lpstat}}} command, like so:

{{{ andre@megatron$ lpstat Queue Dev Status Job Files User PP % Blks Cp Rnk ------- ----- --------- --- ------------------ ---------- ---- -- ----- --- --- xp335_c @mega READY }}}

You can also use {{{lsallq}}} command to quickly display all printer queues configured on an AIX machine:

{{{ $ lsallq hp04_ps hp04_acm hp04 hp01 megatron_printer lpd_acmecorp lpd_megacorp }}}

==== 2. Stop a printer queue. ====

Stopping a printer queue under AIX is something that helps when a printer is marked as {{{DOWN}}}.

To stop a printer queue, use the following {{{enq -K -P 'name_of_queue'}}}:

{{{ enq -K -P 'megatron_printer' }}}

==== 3. Start a printer queue. ====

Starting a printer queue is almost the same as stopping it:

{{{ enq -U -P 'megatron_printer' }}}

==== 4. Deleting a file from a printer queue. ====

Useful when a printer queue does not want to restart despite all your best efforts:

{{{ lprm -P 'megatron_printer' 480 }}}

This removes job #480 from the printer queue named {{{'megatron_printer'}}}.

After doing this, just use {{{enq}}}, as noted above, to stop and restart the printer queue.

You can also use the {{{qcan}}} command to cancel a job.

==== 5. Automated printer queue check. ====

Here is a short script to automatically check and restart printer queues if needed. This script requires GNU bash to be installed on your AIX machine.

Please replace 'REPLACE' and 'EMAIL' in the following script to adapt it to your needs.

{{{ #!/usr/local/bin/bash

# ############################################################## # # # # check_printers.sh # # Automatically checks printer queues: # # 1) Kill all queues if one is marked as DOWN # # 2) Restart all queues # # 3) Warn administrators about queue problems # # # # This is designed for a system with many printer queues, # # using distant (networked) printers. Add as many printers # # as needed in the different 'enq' commands below. # # # # Modify as follows: # # ================== # # REPLACE -> name of printer queues # # EMAIL -> email of admins to be informed. # # # ##############################################################

check=$(lpstat | grep -i ^REPLACE.*DOWN | grep -vi HOST | wc -l | awk '{print $1}') system=`uname -n`

case ${check} in "0") # No 'DOWN' queue: exit exit 0 ;; *) # At least one DOWN queue: # kill, restart and inform.

# Kill ------------------------ enq -K -P 'REPLACE' # add more printers here if needed.

# Restart --------------------- enq -U -P 'REPLACE' # add more printers here if needed.

# Inform ---------------------- echo "At least one printer queue DOWN on ${system}. Printer queue restarted. Please check printer status." |\ mail -s "Printer queues on ${system}" EMAIL -c EMAIL ;; esac

exit 0

# end of script. }}}

Please note that this is a very basic script: stick it in the {{{root}}} crontab and let it do its magic.

Improvements to this script are easy, and left as an exercice to the reader... ;-)

(Do share your improvements, though!)

== See Also: ==