Linux (CUPS) Spooler Troubleshooting

Step 1:Check Error logs

Command:    tail -f /var/log/cups/error_log 

I [08/Mar/2017:16:58:03 +0300] [Job ???] Request file type is text/plain.
 I [08/Mar/2017:16:58:03 +0300] [Job 7] Adding start banner page "none".
 I [08/Mar/2017:16:58:03 +0300] [Job 7] Adding end banner page "none".
 I [08/Mar/2017:16:58:03 +0300] [Job 7] File of type text/plain queued by "emdadm".
 I [08/Mar/2017:16:58:03 +0300] [Job 7] Queued on     
 "TEST_LABEL_PRINTER" by "emdadm".

Linux (CUPS) Spooler Commands

Step 2:To view the status of all print queues:

Command:    lpc status

Example:

serddad1:~ # lpc status
 TEST_LABEL_PRINTER:
 printer is on device 'socket' speed -1
 queuing is enabled
 printing is enabled
 1 entries
 daemon present

PROD_LABEL_PRINTER:
 printer is on device 'socket' speed -1
 queuing is enabled
 printing is enabled
 1 entries
 daemon present

Step 3:To check the status of a single print queue and view a list of pending jobs:

Command:  lpc status printer_name,  lpstat -P printer_Name,

lpstat -pprinter_name

Example:

serddad1:~ # lpc status TEST_LABEL_PRINTER
 TEST_LABEL_PRINTER:
 printer is on device 'socket' speed -1
 queuing is enabled
 printing is enabled
 1 entries
 daemon present
 serddad1:~ # lpstat -P TEST_LABEL_PRINTER
 TEST_LABEL_PRINTER-1 root 17408 Tue Feb 28 14:38:09 2017
 serddad1:~ # lpstat -pTEST_LABEL_PRINTER
 printer TEST_LABEL_PRINTER is idle. enabled since Thu Mar 9 14:30:20 2017

Step 4:To remove a single print job:

Command:  cancel printer_name-id(check output of lpstat -P TEST_LABEL_PRINTER)  ,

Example:

serddad1:~ # cancel TEST_LABEL_PRINTER-1

Step 5:To remove all print jobs in a queue:

Command: cancel -a  printer_name

Example:

serddad1:~ # cancel -a TEST_LABEL_PRINTER

Step 6:To enable  a queue:

Command:cupsenable  printer_name

Example:

serddad1:~ # cupsenable TEST_LABEL_PRINTER

Step 7:To disable  a queue:

Command:cupsdisable  printer_name

Example:

serddad1:~ # cupsdisable TEST_LABEL_PRINTER

Step 8:To enable all queues:

Command:

lpstat -p | grep disabled | awk '{print $2}' | xargs cupsenable

Example:

serddad1:~ #lpstat -p | grep disabled | awk '{print $2}' | xargs cupsenable

Step 9:To print a test job:

Command:

echo test_page | lpr -P printer_name

Example:

serddad1:~ #echo test_page | lpr -P  TEST_LABEL_PRINTER

Step 10:To restart/refresh the cups service:

Command:

service cups restart

Install Cups(Common Unix Printing System) to configure network printer with commands.

Install cups(Common Unix Printing System)

[root@lynx /]#  yum -y install cups  

OR

rpm -ivh  cups-1.4.2-74.el6.x86_64.rpm

Configure Cups

[root@lynx /]# vim /etc/cups/cupsd.conf
MaxLogSize 2000000000

LogLevel info

SystemGroup sys root

# line 19: change

Listen localhost:631
Listen /var/run/cups/cups.sock

Browsing On
BrowseOrder allow,deny
BrowseAllow @LOCAL

DefaultAuthType Basic

# line 31: add access permition

<Location />
Order allow,deny

Allow 172.40.1.0/24
</Location>

# line 37: add access permition

<Location /admin>
Encryption Required
Order allow,deny

Allow 172.40.1.0/24
</Location>

# line 43: add access permition

<Location /admin/conf>
AuthType Default
Require user @SYSTEM
Order allow,deny

Allow 172.40.1.0/24
</Location>

<Policy default>
# Job-related operations must be done by the owner or an administrator…
<Limit Send-Document Send-URI Hold-Job Release-Job Restart-Job Purge-Jobs Set-Job-Attributes Create-Job-Subscription Renew-Subscription Cancel-Subscription Get-Notifications Reprocess-Job Cancel-Current-Job Suspend-Current-Job Resume-Job CUPS-Move-Job>
Require user @OWNER @SYSTEM
Order deny,allow
</Limit>

# All administration operations require an administrator to authenticate…
<Limit CUPS-Add-Modify-Printer CUPS-Delete-Printer CUPS-Add-Modify-Class CUPS-Delete-Class CUPS-Set-Default>
AuthType Default
Require user @SYSTEM
Order deny,allow
</Limit>

# All printer operations require a printer operator to authenticate…
<Limit Pause-Printer Resume-Printer Enable-Printer Disable-Printer Pause-Printer-After-Current-Job Hold-New-Jobs Release-Held-New-Jobs Deactivate-Printer Activate-Printer Restart-Printer Shutdown-Printer Startup-Printer Promote-Job Schedule-Job-After CUPS-Accept-Jobs CUPS-Reject-Jobs>
AuthType Default
Require user @SYSTEM
Order deny,allow
</Limit>

# Only the owner or an administrator can cancel or authenticate a job…
<Limit Cancel-Job CUPS-Authenticate-Job>
Require user @OWNER @SYSTEM
Order deny,allow
</Limit>

<Limit All>
Order deny,allow
</Limit>
</Policy>
MaxJobs 9999

[root@lynx /]# /etc/rc.d/init.d/cups start
Starting cups:
[root@lynx /]# /etc/rc.d/init.d/cups status
cupsd (pid 22808) is running…
[root@lynx /]# chkconfig cups on
[root@lynx /]# chkconfig –list cups
cups 0:off 1:off 2:on 3:on 4:on 5:on 6:off
[root@lynx /]#

installation and configuration finished.

Basic printer term

lpadmin:a command line tool used to configure printer and class queues provided by CUPS.

class: server default printer

lpinfo -v:list all the available ports or interfaces available to configure the printer

Adding a New Printer

Syntax:
lpadmin -p printer_info -v lpd://printer_name/printer_name
lpstat -v printer_info

Example:
Printer Name : prnbalcik
Location : Balcik Depo
Device : LPD
DeviceUrl : lpd://prnbalcik/prnbalcik

[root@lynx /]#vim /etc/cups/printers.conf

<Printer prnbalcik>
Info Yarimca sase barkod
Location Balcik Depo
DeviceURI lpd://prnbalcik/prnbalcik
State Idle
StateTime 1468408345
Accepting Yes
Shared Yes
JobSheets none none
QuotaPeriod 0
PageLimit 0
KLimit 0
OpPolicy default
ErrorPolicy stop-printer
</Printer> 

[root@lynx /]# lpstat -v prnbalcik
device for prnbalcik: lpd://prnbalcik/prnbalcik
[root@lynx /]#

OR

[root@lynx /]# lpadmin -p printer_info -v  lpd://prnbalcik/prnbalcik

[root@lynx /]# lpstat -v prnbalcik
device for prnbalcik: lpd://prnbalcik/prnbalcik

Remove printer

[root@lynx /]# lpadmin -x printer_info

OR  delete printer from configuration file.

[root@lynx /]#vim /etc/cups/printers.conf

Add Printer to a Class

[root@lynx /]#lpadmin -h printer_name -p printer_info -c myclass