[an error occurred while processing this directive]

Deleting defunct printers on Solaris and SunOS/DecOSF

Two main sections: Solaris and SunOS/DecOSF.

Solaris: deleting defunct printers using lpadmin, etc.:

Get list of defunct printers:
lpstat -t >& /tmp/lpstat.t.out.`date +\%Y.\%m` &
egrep "unknown printer" /tmp/lpstat.t.out|nawk -F':' '{print $3}'|\
	sed -e '/^$/d' > /tmp/unknown.printers.`date +\%Y.\%m.\%d`

Use rm_printer.sh to delete defunct printers found by above operation.
rm_printer.sh reads

infile=unknown.printers.`date +\%Y.\%m.\%d`
echo $infile
for printer in `cat $infile`
        /usr/ucb/lpq -P $printer
        lpadmin -x $printer
exit 0

to delete the unknown printers

MAKE SURE to DELETE all files in /var/spool/print related to the defunct printer(s). See next section for background on /var/spool/print

Solaris: /var/spool/print, printd and spc

[From an article, whose source is no longer available, formerly at http://x56.deja.com/=dnc/[ST_rn=ps]/getdoc.xp?AN=600723009&CONTEXT=981406799.1185087491&hitnum=3)]

"Printd delivers print jobs to remote printers. Print jobs for remote printers are queued in the /var/spool/print directory (jobs for local or network printers are queued in directories under /var/spool/lp)

When Solaris boots up, the /etc/rc2.d/S80spc startup script runs printd to flush any jobs in /var/spool/print to their printers. When it's finished sending the print jobs that were there at boot time, printd exits.

Print jobs placed in /var/spool/print by lp/lpr commands, or by in.lpd spawn a background process to deliver the job to the remote printer."

So as long as there were jobs spooled for these defunct printers in /var/spool/printd, printd will hammer away, trying to print them.

lpadmin -x defunct printer
/etc/init.d/lp stop
/etc/init.d/lp start

rm or mv or whatever pleases you the files in /var/spool/print for these defunct printers.
You may need to delete the .printd.lock file there, too.

Stopping/starting spc, which runs printd

/etc/init.d/spc stop
/etc/init.d/spc start

[stop and start printd]

If /var/spool/print is clear, printd should go away ...

SunOS/DecOSF: deleting defunct printers

  1. cd /etc/
  2. cp -p printcap printcap.modtime
    "modtime" is MM.DD.YYYY of modtime for printcap
  3. nawk -F':' '{print $1}' < printcap|sed -e '/^#/d'|sed -e 's?\|.*$??' >/tmp/printers.list
  4. cd /tmp
  5. touch printers.log
  6. run /var/spool/lpd/MAINT/test_printer.sh
    Contents of /var/spool/lpd/MAINT/test_printer.sh
    for printer in `cat printers.list`
    	lpq -P $printer >> printers.log
    exit 0
  7. egrep "unknown printer" printers.log | nawk -F':' '{print $3}' | sed -e '/^$/d' | sed -e 's/^ //' > /tmp/unknown.printers
  8. NOTE WELL: steps involving sed work ONLY if /etc/printcap has ONE line per printer!!! NOTE WELL: If /etc/printcap has MULTIPLE lines per printer, do NOT use sed method shown below.
    delete the defunct printers by an editor or other method.

    1. sed -f make_deletes.sed < unknown.printers > unknown_printers.sed
    2. sed -f unknown_printers.sed < /etc/printcap > printcap.new
    NOTE WELL: Do next step AFTER removing defunct printers from /etc/printcap
  9. mv /tmp/printcap.new /etc/printcap
  10. cd /var/spool/lpd
  11. Run /var/spool/lpd/MAINT/delete_defunct_spooldirs.sh
    to delete spool dirs. of deleted printers.
    Contents of /var/spool/lpd/delete_defunct_spooldirs.sh
    # run this in /var/spool/lpd
    for dir in `cat /tmp/unknown.printers`
    /bin/rm -rf /var/spool/lpd/$dir
    exit 0
NOTE WELL: Dec/OSF seems to require stopping/starting lpd for changes to take full effect.
Last modified Tue Mar 21 16:28:27 PST 2006