IT/Procedures/Printer Maintenance/Script to prevent printhead drying out: Difference between revisions
< IT | Procedures
Access restrictions were established for this page. If you see this message, you have no access to this page.
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
= Printer Maintenance Script = | = Printer Maintenance Script = | ||
This script tries to print out pages every few days on all inkjet printers. | |||
This should prevent the ink drying out which would render the printer unusable. | |||
This should prevent the ink drying out which | |||
=== How is it setup? === | === How is it setup? === | ||
* the script runs every few days as a cron job on the cnx server | * the script runs every few days as a cron job on the cnx server | ||
* several scripts are under /home/walt/.scripts/PrinterMaintenance | * several similar/other scripts are under /home/walt/.scripts/PrinterMaintenance | ||
** the most current script is named printer-maintenance.sh | |||
* <code>crontab -e</code> to check which one is active at the moment | * <code>crontab -e</code> to check which one is active at the moment | ||
* the | * the current cronjob creates logs in the same folder (*.log) | ||
* most if not all scripts try to print with lp and check somewhat with <code>lpstat</code> what's around (printers and/or open print jobs) | * most if not all of the scripts try to print with lp and check somewhat with <code>lpstat</code> what's around (printers and/or open print jobs) | ||
=== Scripts Overview === | |||
* there's a script that prints over the access point mode of the printers | * 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 | ** caveat is that the printer need to be set to ap mode, then back again for normal use | ||
Line 23: | Line 19: | ||
* the other scripts try to print over wlan connected to the router | * 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 | ** this seems to work "mostly" well, at least with the MG3670 printer models | ||
** depending on the | ** depending on the configured drivers in CUPS it will not print anything at all | ||
=== | === Issues === | ||
* some printers occasionally just don't print anymore and pile up jobs (check <code>lpstat</code>) | * some printers occasionally just don't print anymore and pile up jobs (check <code>lpstat</code>) | ||
** though this also happens | ** though this also happens for "legit" reasons, e.g. no paper or printer error | ||
** mainly this happens if the correct driver is not configured in cups | |||
* printers sometimes "dissapear" from the network and are no longer visible through e.g. <code>lpstat -v</code> | * printers sometimes "dissapear" from the network and are no longer visible through e.g. <code>lpstat -v</code> | ||
* so far | ** so far this has been mitigated by setting the printers up in cups with a static IP address over ipp | ||
=== | === printer-maintenance.sh === | ||
* configured | * configured a specific printer driver/model in CUPS | ||
** the default model doesn't support duplex and CMYK printing | ** the default/driverless 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 ;) | ** set address from dnssd (bonjour) to static ip of the printer so that they don't suddenly dissappear (to the next volunteer: just change it back if you think this should be done with bonjour ;) | ||
** see [[IT/Procedures/Printer Maintenance/Configure Printer Driver-Model|Configure Printer Driver/Model]] | ** see [[IT/Procedures/Printer Maintenance/Configure Printer Driver-Model|Configure Printer Driver/Model]] | ||
* printer-maintenance.sh | * printer-maintenance.sh | ||
Line 43: | Line 39: | ||
** checks if a printer has any unfinished jobs and deletes them (<code>lprm [PRINTER] -</code>) | ** checks if a printer has any unfinished jobs and deletes them (<code>lprm [PRINTER] -</code>) | ||
** checks if a printer has the correct driver/model configured, searches for the ColorModel attribute (<code>lpoptions -p [PRINTER_NAME] -l | grep ColorModel | grep CMYK</code>) | ** checks if a printer has the correct driver/model configured, searches for the ColorModel attribute (<code>lpoptions -p [PRINTER_NAME] -l | grep ColorModel | grep CMYK</code>) | ||
*** could probably also be done with e.g. <code>lpoptions -p [PRINTER_NAME] | grep "Canon MX920 series - CUPS+Gutenprint v5.3.3"</code> but would need a different string for every printer model | *** could probably also be done with e.g. <code>lpoptions -p [PRINTER_NAME] | grep "Canon MX920 series - CUPS+Gutenprint v5.3.3"</code> but would need a different string compare for every printer model | ||
** sends a new job | ** sends a new print job | ||
** waits | ** waits 3 min for the page to print, then checks for unfinished jobs again | ||
*** if there are some, this will be logged | *** if there are some, this will be logged | ||
*** those printers then need manual maintenance (mechanical issue, wrong driver, or just | *** those printers then need manual maintenance (probably mechanical issue, wrong driver, or just missing paper) | ||
*** sends notification to telegram webhook with output of lpstat | *** sends a notification to telegram and/or line webhook with output of lpstat | ||
**** could be extended to send to e-mail or | **** could be extended to send to e-mail or other messengers if needed | ||
==== Telegram Notifications ==== | ==== Telegram Notifications ==== | ||
How to setup Telegram notifications. | |||
* contact "BotFather" to create a new telegram bot send: /newbot | In Telegram: | ||
* contact "BotFather" to create a new telegram bot and send: /newbot | |||
* follow the instructions | * follow the instructions | ||
Line 61: | Line 59: | ||
* contact "IDBot" and send: /getid (in a group chat, add IDBot to group and send: /getgroupid@myidbot) | * contact "IDBot" and send: /getid (in a group chat, add IDBot to group and send: /getgroupid@myidbot) | ||
** this will show you your chat ID or the one of a group chat | |||
** copy the ID (include "-" with group chat IDs") | |||
* paste the API key and ID into the script | |||
** <code>TELEGRAM_API_TOKEN</code> | |||
** <code>TELEGRAM_CHAT_ID</code> | |||
* | ==== Line Notifications ==== | ||
* paste the | How to setup Line notifications. | ||
* visit https://notify-bot.line.me/my/ | |||
* click Generate token | |||
** choose a name | |||
** choose the group chat to where the notifications will be sent to | |||
* save the token and paste it to <code>LINE_ACCESS_TOKEN</code> | |||
* add the account "LINE Notify" to the group chat | |||
* more information: https://notify-bot.line.me/doc/en/ | |||
=== Useful Commands === | === Useful Commands === |
Latest revision as of 14:45, 27 May 2024
Printer Maintenance Script
This script tries to print out pages every few days on all inkjet printers.
This should prevent the ink drying out which would render the printer unusable.
How is it setup?
- the script runs every few days as a cron job on the cnx server
- several similar/other scripts are under /home/walt/.scripts/PrinterMaintenance
- the most current script is named printer-maintenance.sh
crontab -e
to check which one is active at the moment- the current cronjob creates logs in the same folder (*.log)
- most if not all of the scripts try to print with lp and check somewhat with
lpstat
what's around (printers and/or open print jobs)
Scripts Overview
- 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 configured drivers in CUPS it will not print anything at all
Issues
- some printers occasionally just don't print anymore and pile up jobs (check
lpstat
)- though this also happens for "legit" reasons, e.g. no paper or printer error
- mainly this happens if the correct driver is not configured in cups
- printers sometimes "dissapear" from the network and are no longer visible through e.g.
lpstat -v
- so far this has been mitigated by setting the printers up in cups with a static IP address over ipp
printer-maintenance.sh
- configured a specific printer driver/model in CUPS
- the default/driverless model doesn't support duplex and CMYK printing
- set address from dnssd (bonjour) to static ip of the printer so that they don't suddenly dissappear (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 compare for every printer model
- could probably also be done with e.g.
- sends a new print job
- waits 3 min for the page to print, then checks for unfinished jobs again
- if there are some, this will be logged
- those printers then need manual maintenance (probably mechanical issue, wrong driver, or just missing paper)
- sends a notification to telegram and/or line webhook with output of lpstat
- could be extended to send to e-mail or other messengers if needed
Telegram Notifications
How to setup Telegram notifications.
In Telegram:
- contact "BotFather" to create a new telegram bot and 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)
- this will show you your chat ID or the one of a group chat
- copy the ID (include "-" with group chat IDs")
- paste the API key and ID into the script
TELEGRAM_API_TOKEN
TELEGRAM_CHAT_ID
Line Notifications
How to setup Line notifications.
- visit https://notify-bot.line.me/my/
- click Generate token
- choose a name
- choose the group chat to where the notifications will be sent to
- save the token and paste it to
LINE_ACCESS_TOKEN
- add the account "LINE Notify" to the group chat
- more information: https://notify-bot.line.me/doc/en/
Useful Commands
lp
lpstat
-e
-v
lprm [PRINTER] -
lpoptions -p [PRINTER_NAME] -l