8

Every once in a while (not necessarily after resuming from suspend or booting) I have to sudo /etc/init.d/cups restart to see again the network printers. Is there a way to bypass this process, or what is the best way to automate it under Lubuntu 16.04?

7
  • Printing has always been fiddly in my experience. Perhaps use a nightly crontab job to bounce the service? Commented Feb 1, 2017 at 16:09
  • @thrig I thought of that, launching when it needs restart; but how to detect this situation? I had ubuntu installed in this machine before and this was not necessary, but yes, printing means trouble. Commented Feb 1, 2017 at 16:27
  • In the configuration of CUPS (/etc/cups/printers.conf) for each printer there is an entry ErrorPolicy. If this is set to stop-printer, the printer que will be stopped when the printer (temporarily) is not reachable, what could happen with network printers. Set this to retry-job, so CUPS won't stop the queue and retry the print job later. See e.g. superuser.com/questions/280396/… Commented Feb 1, 2017 at 16:38
  • Is Ubuntu the exact same version as before? For detection, the various lp* commands may indicate what CUPS can see. Commented Feb 1, 2017 at 16:41
  • @thrig right, lpq -l might do it. I was using Ubuntu 14.04. Commented Feb 1, 2017 at 17:48

1 Answer 1

2

For Linux based shell script you can try to schedule script as below:

Crontab entry:

*/5 * * * * sh /scripts/cups_recursive_checking.sh 
#/bin/sh HOST='server-name' /etc/init.d/cups status>/scripts/cups.txt if grep "cupsd (pid " /scripts/cups.txt then echo "cups is already running" exit else /etc/init.d/cups restart echo "cups just now started in server-name" ############# For mail Notification whenever cups gets restart follow below line according to your email ########## mutt -e "my_hdr Content-Type: text/html" -e 'set realname=Notification' \ -e 'set [email protected]' [email protected] \ -s "CUPS Notification" < /scripts/cups.txt fi ###END OF THE SCRIPT### 

Example : To check the printers after the cups restart in Linux

lpstat -a clientPrinter accepting requests since Sat 13 Jul 2019 10:07:01 AM IST dmx accepting requests since Sat 13 Jul 2019 03:55:05 PM IST HP_LaserJet_400_M401dw accepting requests since Sat 13 Jul 2019 03:05:06 PM IST 

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.