[OPEN-ILS-DOCUMENTATION] Documentation regarding cron jobs

Nathanael Schilling nathanaelschilling at gmx.net
Thu Mar 5 14:54:33 EST 2009


I realised that there was not documentation for setting up cron jobs for 
evergreen, and that I hadn't done it myself already, so I decided to write 
some while I was going along. Its VERY incomplete, and probably has 
quite a few errors somebody should check though
Nathanael Schilling

Cron Jobs
Certain evergreen scripts need to be run at specific intervals. An 
example of this is the reshelving_complete script, which checks how long 
books have been in the reshelving status, and then flips them from the 
Reshelving copy status to the Available one. We will be using Cron for 
scheduling these scripts.
1)The Reshelving->Available script.
This script, as mentioned earlier flips books from the reshelving to the 
available status. It resides in /openils/bin/reshelving_complete.srfsh . You 
will need to set a value for how long it takes your library to reshelve 
books. Open the reshelving_complete.srfsh file with your favourite text 
editor.
You should get something like this:
<file>
#!/openils/bin/srfsh
request open-ils.storage open-
ils.storage.action.circulation.reshelving.complete "24h"
</file>
change the last part of line 2 (24h) to the length it takes your library to 
reshelve the book. This value can be seconds(e.g. 3s), minutes(e.g. 
23m) or hours(e.g. 2h) or a mixture of these(e.g. 2h3m1s). The resulting 
line should look something like this:

<file>
request open-ils.storage open-
ils.storage.action.circulation.reshelving.complete "3h2m1s"
</file>

In this example, the reshelving interval is 3h2m1s. Run the script to test 
whether it worked, if you get an error message , the reshelving interval 
was probably not set correctly, try setting it again.

2)The thaw expired holds script
This script resides in /openils/bin/thaw_expired_frozen_holds.srfsh 

3)The fine generator script
You'll find this script in /openils/bin/fine_generator.pl
This script generates your fines.
You'll need to add the argument  /openils/conf/opensrf_core.xml to this 
script later on.

4)The find orphaned reports script
This script sits in /openils/bin/find_orphaned_reports.pl
the name is self explanatory

5)The long overdue status update script
This script sits in /openils/bin/long-overdue-status-update.pl
You'll need to add “/openils/conf/opensrf_core.xml” and a number to 
specify what you mean with “long” as arguments later on.
Note: you'll probably not need this one.


6)The Hold Targeter Script
This script can be found in /openils/bin/hold-targeter.pl
You'll need to add “/openils/conf/opensrf_core.xml” as an argument later 
on.


TODO:Find arguments for this script
7)The offline blocked list
This script can be found in /openils/bin/offline-blocked-list.pl
The offline blocked list generates a list of "bad" patrons that the offline 
interface makes use of for warning staff



So, you'll need to set a time for each of these scripts to run. If you 
haven't insThe talled cron yet, you'll need to install it now, it'll probably 
be installed already on most systems. Cron is basically a daemon that 
executes certain commands at regulat intervals. The file we will be editin 
is the opensrf crontab. Each user has their own crontab. It has the 
followin syntax:


minute hour dayofmont month dayofweek user  command

minute- is the minute of the hour the command should run.
hour – The hour it should run
dayofmonth -  the day of month is something like the 10th
month- is the month, eg March. Can be specified as a number or name
dayofweek – What day of the week should a command be run on e.g 
every tuesday. This can be numeric(e.g. 2) or oa name (e.g tues) – Note 
: the numeric value for Sunday is zero (0)
user – The user that should run the command. You'll only need this if 
you're editing the global crontab
cmd-  The command to be run.

If you wish to leave a value blank, put an asterix there (*)

and here is a sample row in this table:
17 *    * * *   root    do_something

this would run the command do_something  on the 17th minute of every 
hour as the user root.

To edit the opensrf user's crontab, do 
<command>
crontab -e
</command>

For each of the scripts I listed earlier, add an entry.
e.g. if you wanted the  thaw_expired_frozen_holds.srfsh script to be run 
the first minute of every hour, insert something like:
<file>
01 * * * /openils/bin/ reshelving_complete.srfsh
</file>

or, if you want to run the fine_generator.pl at 4am wednesday:

<file>
00 04 * wed /openils/bin/ fine_generator.pl /openils/conf/opensrf_core.xml
</file>


You'll need to add entries for all of the scripts mentioned above. Add the 
arguments specified aboce Set all the cron values to a sensible value, so 
you don't end up running theses scripts every hour. Every day would 
probably be sensible.



More information about the OPEN-ILS-DOCUMENTATION mailing list