Schedule a Report to Run via a Cron Job
Once a report is created and saved into a library’s Koha system, this report can be run via the Schedule tool or scheduled through a cron job.
The
scheduling tool found in Koha currently can be used to schedule a report to run at a specific time on a specific day. Alternatively, a cron job can schedule to run a saved report on a more regular basis (daily, monthly, etc).
Cron Details
When a library has a saved report that they would like to schedule as a cron job, a ticket can be sent to ByWater to set it up. A few more key details are required for the ByWater team to set up the cron report:
- What Report Number would your library like schedule via the cron?
- What email would you like this report emailed to when run?
- What format would your library like this report to be sent to your library?
- What email subject you would like to have to alert you of the email?
- In addition to all this, we will need to know when you would like this run and how often.
An Example Cron
If a library wanted report #42 scheduled to run and the library would like the report sent as a CSV with headers and emailed to
library@library.com. The subject of the email should read “Weekly Circulation Report”.
An example of this cron file would be:

$KOHA_CRON_PATH/runreport.pl --to=”
library@library.com” --subject=”Weekly Circulation Report” --format=csv --csv-header -a 42
Parameters
A report that a library would like to be scheduled through a cron cannot have parameters. Report parameters would be a date range or shelving location selected from a dropdown list. If a library does have a report that they would like to schedule and it does have parameters, we can help with the adjustment of the report.
For example, if the report asked for a date range, the report can be manipulated to look at the last 30 days:

SELECT *
FROM items
WHERE homebranch = <<Pick your branch|branches>>
Instead, the report would need to be changed to specifically say what branch the home branch should be equal to:

SELECT *
FROM items
WHERE homebranch =’EAST’
If your library had a report to show new items in a date range such as this one:

SELECT items.dateaccessioned,biblio.title,items.itemcallnumber
FROM items
LEFT JOIN biblioitems ON (items.biblioitemnumber=biblioitems.biblioitemnumber)
LEFT JOIN biblio ON (biblioitems.biblionumber=biblio.biblionumber)
WHERE DATE (items.dateaccessioned) BETWEEN <<Between (yyyy-mm-dd)|date>> AND <<and (yyyy-mm-dd)|date>>
ORDER BY items.itemcallnumber ASC
An adjustment could be and this would provide the library with a list of new items in the last 30 days:

SELECT items.dateaccessioned,items.itemcallnumber,biblio.title,biblio.author
FROM items
LEFT JOIN biblioitems ON (items.biblioitemnumber=biblioitems.biblioitemnumber)
LEFT JOIN biblio ON (biblioitems.biblionumber=biblio.biblionumber)
WHERE DATE_SUB(CURDATE(),INTERVAL 30 DAY) <= items.dateaccessioned
ORDER BY biblio.title ASC
Related Articles
Notices in Koha
Notices are a powerful way to communicate with patrons about their checked-out materials, holds, renewals, etc. Koha has many options for customizing the notices and customizing how they are delivered, both through settings configuration and through ...
Creating and Running Reports
Koha uses SQL (Structured Query Language) for reports. Basically, you are asking, via SQL, to select certain information from specific fields, where the information matches specified criteria. Of course, libraries who are comfortable with SQL can ...
Koha Item Status Reports
In another article, there was a discussion of a variety of item statuses and how their behavior can be customized in Koha. That article covered everything that is a “status” in Koha: Withdrawn, Lost, Damaged, Restricted, and Not For Loan. However, ...
Using Mana to Import Reports into Koha
The Koha community shares reports through Mana-kb. The setup is the same as for Serials and adds a Mana link in the Reports Module. Using Mana in the Reports Module When creating a SQL report, there is a an option in the dropdown - “New SQL from ...
Koha Glossary of Terms
Find the basics of Koha's vocabulary here. Additional resources: Polaris to Koha Glossary Symphony to Koha Glossary Aspen/Koha Glossary This glossary is in alphabetical order. Use control+F to quickly search this page for specific terms. Authority ...