We sometimes get asked by customers “How can I see what scripts are running on my server?”, or “How can I schedule a report to run regularly and email me the results?”
Unfortunately, Koha doesn’t presently have a means to schedule scripts and reports from within the web interface, but we can schedule them on your behalf through the crontab (task scheduler) on the server.
This means that you actually have a great deal of flexibility on when things run, and what they do. If you want to know exactly what does what and when it does it, we can put a read-only copy of your crontab in your Access Files directory which you can then view through the staff interface. Please note that if you do edit this file, it will have no effect on the timings of your scripts– we need to change it for you.
When you first look at your crontab, it can look a bit daunting and impenetrable, but it’s actually very simple to read.
Take the following two cronjobs (tasks) as examples:
# SEND EMAILS
15 * * * * $KOHA_CRON_PATH/process_message_queue.pl
Firstly, any line starting with # is a comment – we use those to make it clear what the following lines are for – or if you decide you temporarily don’t want a particular script to run, we can comment it out so that it won’t be activated when scheduled.
The numbers and asterisks at the start of the line tell the server when to run the cronjob. In the case of the first line, it runs at 15 minutes past the hour, every hour, every day, every month.
The second script runs at 10.04am on the 28th of each month. We have great flexibility to configure this so that if you just wanted a particular script to run at (e.g.) 5.27am on Mondays,Wednesdays and Saturdays in the months of June, July and December only, we can easily do that for you.
The next part of the line tells the server which script to run. $KOHA_CRON_PATH is just a shorthand code to tell the server where to find the script. In the first line, this is the
process_message_queue.pl script, which sends any email notices that are currently being queued on your server out to your users. The second line is how we instruct the server to schedule and email a report. The 97 refers to the number of the report (you can see these numbers when you view your list of saved reports). You can see that this report is to be emailed in text format to two users, [email protected] and [email protected] We can also configure this to email the output in CSV, TSV or HTML formats. Additionally, if you want to be able to
view the report output directly in a third-party application, we can also set it to include an attachment which you can click on to open Excel or Notepad.
If you would like to view your own crontab, please log a support ticket and we will enable it for you. Most crontabs don’t change much from one year to the next, but in the case of sites where there are a lot of reports being scheduled it can change quite often. If this is the case for you, please ask us to schedule a regular update of your readable copy of the crontab or it will quickly become outdated.