IT/Procedures/Printer Maintenance/Script to prevent printhead drying out
< IT | Procedures
Printer Maintenance Script
About the Issue
A lot of effort has been taken by several people to create a reliable script that prints a test page on all printers every few days.
This should prevent the ink drying out which renders the printer unusable.
So far this feat has not been fully achieved yet :(
How is it setup?
- the script runs every few days as a cron job on the cnx server
- several scripts are under /home/walt/.scripts/PrinterMaintenance
crontab -e
to check which one is active at the moment- the newer ones are set to create some logs in the same folder (*.log)
- most if not all scripts try to print with lp and check somewhat with
lpstat
what's around (printers and/or open print jobs)
What is working so far
- there's a script that prints over the access point mode of the printers
- caveat is that the printer need to be set to ap mode, then back again for normal use
- so far this was used as a "holiday setup"
- the other scripts try to print over wlan connected to the router
- this seems to work "mostly" well, at least with the MG3670 printer models
- depending on the mood of the printer, it will not print anything at all
- send a Telegram notification if any print job ist unfinished
The Issues
- some printers occasionally just don't print anymore and pile up jobs (check
lpstat
)- though this also happens with "legit" reasons, e.g. no paper or printer error
- printers sometimes "dissapear" from the network and are no longer visible through e.g.
lpstat -v
- so far no reliable way has been found to resolve the issues automatically
New Approaches and Findings
- configured another printer driver/model in CUPS
- the default model doesn't support duplex and CMYK printing
- set address from dnssd (bonjour) to static ip of the printer (to the next volunteer: just change it back if you think this should be done with bonjour ;)
- see Configure Printer Driver/Model
- printer-maintenance.sh
- uses a static list of all printers (so no printer is "forgotten" if it dissapears from the network)
- checks if a printer has any unfinished jobs and deletes them (
lprm [PRINTER] -
) - checks if a printer has the correct driver/model configured, searches for the ColorModel attribute (
lpoptions -p [PRINTER_NAME] -l | grep ColorModel | grep CMYK
)- could probably also be done with e.g.
lpoptions -p [PRINTER_NAME] | grep "Canon MX920 series - CUPS+Gutenprint v5.3.3"
but would need a different string for every printer model
- could probably also be done with e.g.
- sends a new job
- waits 1 min, then checks for unfinished jobs again
- if there are some, this will be logged
- those printers then need manual maintenance (mechanical issue, wrong driver, or just more paper)
- sends notification to telegram webhook with output of lpstat
- could be extended to send to e-mail or some other messenger if needed
Telegram Notifications
In Telegram
- contact "BotFather" to create a new telegram bot send: /newbot
- follow the instructions
- copy the API key
- contact "IDBot" and send: /getid (in a group chat, add IDBot to group and send: /getgroupid@myidbot)
- copy ID (include "-" with group chat IDs")
- paste the API key and ID into the script
Useful Commands
lp
lpstat
-e
-v
lprm [PRINTER] -
lpoptions -p [PRINTER_NAME] -l