Koha How-To

Cron Jobs: Run Report

Schedule a Report via a Cron

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).

The Details are in the Cron

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 up this cron job.

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?

Andrew create this helpful blog post on what options are available and what each option looks like: How Would You Like Your Report?

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


A report that a library would like to be scheduled through a cron can not have parameters.

Parameter examples would include if your report asked for a date range or to pick a shelving location 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:

A simple example of what a parameter looks like in a mySQL report:


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:


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

More Cron Documentation

Cron Jobs: Overdue Notices

Monday Minutes: Sharing Usage through Hea

Sending Notices for Long Overdue Items

Monday Minutes: Emailing Customized Patron Notices

Koha Community Github Page: Run Report

Cron Job documentation in the Koha Manual