Back to Knowledege base

Stopping and Starting All Printers Simultaneously

Managing multiple printers for maintenance, updates, and emergencies

Why Stop All Printers?

Common scenarios:

  • System maintenance windows
  • Xi-Text software updates
  • Server shutdown or restart
  • Hardware maintenance
  • Emergency situations
  • Network maintenance
  • Printer firmware updates

Stopping all printers ensures clean state and prevents print job interruptions during maintenance.

Understanding Printer State

Before stopping printers:

Printers can be in various states:

  • Printing (actively processing job)
  • Idle (ready to print)
  • Shutdown (shutting down process)
  • Halted (stopped, not processing)
  • Error (problem state)
  • Offline (not available)

Halt vs Kill:

Halt at end of job (graceful) : Lets current job finish, then stops printer

Kill/Abort (immediate) : Stops printer immediately, current job aborted

Command-Line Approach

List all printers:

bash

splist

Shows all configured printers with their states.

Stop single printer (graceful):

bash

sphalt <printer_name>

Waits for current job to complete.

Stop all printers with script:

bash

#!/bin/bash
# halt-all-printers.sh

for printer in $(splist -F "%P" | tail -n +2); do
    echo "Halting printer: $printer"
    sphalt "$printer"
done

echo "All printers halting..."

Immediate stop (abort current jobs):

bash

#!/bin/bash
# abort-all-printers.sh

for printer in $(splist -F "%P" | tail -n +2); do
    echo "Aborting printer: $printer"
    spoper -A "$printer"
done

echo "All printers aborted."

Starting All Printers

Start single printer:

bash

spoper -G <printer_name>

Or:

bash

spstart <printer_name>

Start all printers script:

bash

#!/bin/bash
# start-all-printers.sh

for printer in $(splist -F "%P" | tail -n +2); do
    echo "Starting printer: $printer"
    spoper -G "$printer"
done

echo "All printers started."

Using spq for Bulk Operations

Interactive method:

In spq:

  1. Press o to switch to printer list
  2. Use cursor to select first printer
  3. Press h (halt at end of job) or H (halt immediately)
  4. Repeat for each printer

No built-in "halt all" function in spq - must process individually.

Production-Ready Scripts

Graceful Halt All

bash

#!/bin/bash
# graceful-halt-all.sh
# Halts all printers, waiting for jobs to complete

TIMEOUT=300  # 5 minute timeout per printer

echo "Halting all printers gracefully..."
echo "Started at $(date)"

for printer in $(splist -F "%P" | tail -n +2); do
    # Check current state
    state=$(splist -F "%t" "$printer")
    
    if [[ "$state" =~ (halted|offline|error) ]]; then
        echo "  $printer: already stopped ($state)"
        continue
    fi
    
    echo "  $printer: requesting halt..."
    sphalt "$printer"
    
    # Wait for halt to complete
    elapsed=0
    while [ $elapsed -lt $TIMEOUT ]; do
        state=$(splist -F "%t" "$printer")
        if [[ "$state" =~ (halted|error) ]]; then
            echo "  $printer: halted ($state)"
            break
        fi
        sleep 5
        elapsed=$((elapsed + 5))
    done
    
    if [ $elapsed -ge $TIMEOUT ]; then
        echo "  $printer: WARNING - timeout waiting for halt"
    fi
done

echo "Completed at $(date)"

Start All with Verification

bash

#!/bin/bash
# start-all-verified.sh
# Starts all halted printers and verifies startup

echo "Starting all printers..."
echo "Started at $(date)"

for printer in $(splist -F "%P" | tail -n +2); do
    # Check current state
    state=$(splist -F "%t" "$printer")
    
    if [[ ! "$state" =~ halted ]]; then
        echo "  $printer: not halted ($state), skipping"
        continue
    fi
    
    echo "  $printer: starting..."
    spoper -G "$printer" 2>&1
    
    # Brief pause for initialization
    sleep 2
    
    # Verify started
    new_state=$(splist -F "%t" "$printer")
    if [[ "$new_state" =~ (startup|idle) ]]; then
        echo "  $printer: started successfully ($new_state)"
    else
        echo "  $printer: WARNING - unexpected state ($new_state)"
    fi
done

echo "Completed at $(date)"

Maintenance Window Workflow

Complete maintenance sequence:

bash

#!/bin/bash
# maintenance-window.sh

echo "=== Maintenance Window Started ==="
echo "Time: $(date)"

# 1. Stop new job submissions
echo "Step 1: Suspending job processing..."
ssuspend 3600  # Suspend for 1 hour

# 2. Halt all printers gracefully
echo "Step 2: Halting all printers..."
/usr/local/bin/graceful-halt-all.sh

# 3. Verify all stopped
echo "Step 3: Verifying all printers halted..."
if splist | grep -v "halted\|offline\|error" | grep -q "Printing\|Idle"; then
    echo "WARNING: Some printers still active"
    splist
else
    echo "All printers confirmed halted"
fi

# 4. Perform maintenance
echo "Step 4: Ready for maintenance tasks"
echo "Run your maintenance commands now"
echo "Press Enter when maintenance complete..."
read

# 5. Restart all printers
echo "Step 5: Starting all printers..."
/usr/local/bin/start-all-verified.sh

# 6. Resume job processing
echo "Step 6: Releasing job suspension..."
srelease

echo "=== Maintenance Window Complete ==="
echo "Time: $(date)"

Emergency Stop

Quick shutdown of everything:

bash

#!/bin/bash
# emergency-stop.sh
# Immediate abort of all printing

echo "EMERGENCY STOP - Aborting all printers"

for printer in $(splist -F "%P" | tail -n +2); do
    spoper -A "$printer" 2>&1 | grep -v "already halted" &
done

wait

echo "All printers aborted."
echo "Run start-all-verified.sh to restart when ready."

Selective Operations

Stop only specific form type:

bash

#!/bin/bash
# halt-form-type.sh
# Halt all printers using specific form

FORM_TYPE="$1"

if [ -z "$FORM_TYPE" ]; then
    echo "Usage: $0 <form_type>"
    exit 1
fi

echo "Halting all printers with form type: $FORM_TYPE"

for printer in $(splist -F "%P %f" | awk -v form="$FORM_TYPE" '$2 == form {print $1}'); do
    echo "  Halting: $printer"
    sphalt "$printer"
done

Stop only local printers (not remote):

bash

#!/bin/bash
# halt-local-printers.sh

echo "Halting local printers only..."

for printer in $(splist -F "%P %l" | awk '$2 == "Yes" {print $1}'); do
    echo "  Halting: $printer"
    sphalt "$printer"
done

Integration with System Shutdown

Add to system shutdown scripts:

bash

# /etc/init.d/xitext or systemd unit

stop() {
    echo "Stopping Xi-Text..."
    
    # Halt all printers gracefully
    /usr/local/bin/graceful-halt-all.sh
    
    # Stop Xi-Text scheduler
    sstop
}

Systemd service example:

ini

[Unit]
Description=Xi-Text Print Spooler
After=network.target

[Service]
Type=forking
ExecStart=/usr/bin/spstart
ExecStop=/usr/local/bin/graceful-halt-all.sh
ExecStop=/usr/bin/sstop
TimeoutStopSec=600

[Install]
WantedBy=multi-user.target

Monitoring During Bulk Operations

Watch all printers during halt:

bash

# In separate terminal
watch -n 2 'splist -F "%P %t"'

Check for stuck printers:

bash

#!/bin/bash
# check-stuck-printers.sh

echo "Checking for printers not responding to halt..."

for printer in $(splist -F "%P %t" | grep -v halted | awk '{print $1}'); do
    state=$(splist -F "%t" "$printer")
    echo "  $printer: $state"
done

Troubleshooting

Printers not halting:

bash

# Check if jobs are preventing halt
splist -l <printer_name>

# Force abort if necessary
spoper -A <printer_name>

Printers not starting:

bash

# Check error log
tail -50 /usr/spool/spd/spshed_reps

# Check printer state
splist -l <printer_name>

# Verify printer setup file
ls -l /usr/spool/spd/<printer_name>

Permission issues:

bash

# Run with appropriate privileges
sudo /usr/local/bin/halt-all-printers.sh

Best Practices

Before stopping all printers:

  • Notify users of maintenance window
  • Check for critical jobs in queue
  • Save printer state for reference
  • Document reason for shutdown

During maintenance:

  • Monitor printer states
  • Keep logs of operations
  • Test thoroughly before resuming
  • Verify all printers restart properly

After restarting:

  • Verify all printers in correct state
  • Check error logs
  • Monitor first few jobs
  • Confirm job processing resumes

Script location:

Store bulk operation scripts in /usr/local/bin/ or /usr/local/sbin/.

Logging:

Add logging to scripts:

bash

exec > >(tee -a /var/log/printer-operations.log)
exec 2>&1

Testing:

Test scripts on non-production system first. Verify graceful handling of:

  • Already-halted printers
  • Error state printers
  • Offline printers
  • Network printers

Quick Reference

Stop all printers:

bash

for p in $(splist -F "%P" | tail -n +2); do sphalt "$p"; done

Start all printers:

bash

for p in $(splist -F "%P %t" | awk '$2 == "halted" {print $1}'); do spoper -G "$p"; done

Count printers by state:

bash

splist | awk '{print $NF}' | sort | uniq -c

List only halted printers:

bash

splist | grep halted

Verify all printers halted:

bash

! splist | grep -v "halted\|offline\|error" | grep -q "Printing\|Idle"

The key to reliable bulk printer operations is using scripts with proper error handling, verification steps, and logging. This ensures smooth maintenance windows and rapid recovery from emergencies.

Introduction to Xi-Batch Diagnostic Helpers
Read-only diagnostic tools for Xi-Batch system administrators