dce95d82ead1a038f99d54aecf1170088212fc53
[kohadocs.git] / en / source / 16_cron_jobs.rst
1 .. include:: images.rst
2
3
4 Cron Jobs
5 =========
6
7 A cron job is a Linux command for scheduling a command or script on your
8 server to complete repetitive tasks automatically. Scripts executed as a
9 cron job are typically used to modify files or databases; however, they
10 can perform other tasks that do not modify data on the server, like
11 sending out email notifications. Koha has many cron jobs in place that
12 you can enable (search engine indexing, overdue notice generation, data
13 cleanup and more), this chapter will explain those for you.
14
15 Crontab example
16 -------------------------
17
18 An example of a Koha crontab can be found in misc/cronjobs/crontab.example
19
20 The example includes sample boilerplate cronjob entries for the most
21 commonly-used cronjobs.
22
23 .. _cron-jobs-subchapter-label:
24
25 Cron Jobs
26 -------------------------
27
28 The locations below assume a dev install which puts the crons in misc/,
29 if you have a standard install you may want to look in bin/ for these
30 files if you cannot find them in misc/
31
32 .. _daily-backup-label:
33
34 Backup
35 ~~~~~~~~~~~~~~~~~~~~~~~~
36
37 Daily Backup
38 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
39
40 Script path: misc/cronjobs/backup.sh
41
42 Does: Creates a daily backup of the Koha database.
43
44 Frequency suggestion: daily
45
46 .. _search-label:
47
48 Search
49 ~~~~~~~~~~~~~~~~~~~~~~~~
50
51 .. _rebuild-index-label:
52
53 Rebuild Index
54 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
55
56 Script path: misc/migration\_tools/rebuild\_zebra.pl
57
58 Does: Updates Zebra indexes with recently changed data.
59
60 Required by: Zebra
61
62 Frequency suggestion: every x minutes, (between 5-15 minutes) depending
63 on performance needs
64
65 .. _circulation-label:
66
67 Circulation
68 ~~~~~~~~~~~~~~~~~~~~~~~~~~~
69
70 .. _holds-queue-label:
71
72 Holds Queue
73 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
74
75 Script path: misc/cronjobs/holds/build\_holds\_queue.pl
76
77 Does: Updates holds queue report
78
79 Required by: :ref:`Holds Queue Report <holds-queue-label>`
80
81 Frequency suggestion: every 1-4 hours
82
83 Description:
84
85 -  A script that should be run periodically if your library system
86    allows borrowers to place on-shelf holds. This script decides which
87    library should be responsible for fulfilling a given hold request.
88
89    It's behavior is controlled by the system preferences
90    :ref:`StaticHoldsQueueWeight <staticholdsqueueweight,-holdsqueueskipclosed-&-randomizeholdsqueueweight-label>` and
91    :ref:`RandomizeHoldsQueueWeight <staticholdsqueueweight,-holdsqueueskipclosed-&-randomizeholdsqueueweight-label>`.
92
93    If you do not want all of your libraries to participate in the
94    on-shelf holds fulfillment process, you should list the the libraries
95    that \*do\* participate in the process here by inputting all the
96    participating library's branchcodes, separated by commas ( e.g.
97    "MPL,CPL,SPL,BML" etc. ).
98
99    By default, the holds queue will be generated such that the system
100    will first attempt to hold fulfillment using items already at the
101    pickup library if possible. If there are no items available at the
102    pickup library to fill a hold, build\_holds\_queue.pl will then use
103    the list of libraries defined in StaticHoldsQueueWeight. If
104    RandomizeHoldsQueueWeight is disabled ( which it is by default ), the
105    script will assign fulfillment requests in the order the branches are
106    placed in the StaticHoldsQueueWeight system preference.
107
108    For example, if your system has three libraries, of varying sizes (
109    small, medium and large ) and you want the burden of holds
110    fulfillment to be on larger libraries before smaller libraries, you
111    would want StaticHoldsQueueWeight to look something like
112    "LRG,MED,SML".
113
114    If you want the burden of holds fulfillment to be spread out equally
115    throughout your library system, simply enable
116    RandomizeHoldsQueueWeight. When this system preference is enabled,
117    the order in which libraries will be requested to fulfill an on-shelf
118    hold will be randomized each time the list is regenerated.
119
120    Leaving StaticHoldsQueueWeight empty is contraindicated at this time.
121    Doing so will cause the build\_holds\_queue script to ignore
122    RandomizeHoldsQueueWeight, causing the script to request hold
123    fulfillment not randomly, but by alphabetical order.
124
125 .. _expired-holds-label:
126
127 Expired Holds
128 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
129
130 Script path: misc/cronjobs/holds/cancel\_expired\_holds.pl
131
132 Does: By default, this cron job will only automatically cancel holds
133 where the user has set an expiration date. If the library is using the
134 :ref:`ExpireReservesMaxPickUpDelay` and
135 :ref:`ExpireReservesMaxPickUpDelayCharge`
136 preferences then this script will also cancel holds that have been
137 sitting on the hold shelf for too long and will (if the library does)
138 charge the patron for not picking up the hold.
139
140 Frequency suggestion: daily
141
142 .. _unsuspend-holds-label:
143
144 Unsuspend Holds
145 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
146
147 Script path: misc/cronjobs/holds/auto\_unsuspend\_holds.pl
148
149 Does: This script checks to find holds that should no longer be
150 suspended and removes the suspension if the
151 :ref:`AutoResumeSuspendedHolds` preference is
152 set to 'allow'. This puts the patron back in to the queue where they
153 were when the hold was suspended.
154
155 Frequency suggestion: daily
156
157 .. _fines-label:
158
159 Fines
160 ^^^^^^^^^^^^^^^^^^^^^^^^^
161
162 Script path: misc/cronjobs/fines.pl
163
164 Does: Calculates and posts fines to patron accounts.
165
166 Required by: :ref:`finesMode` system preference
167
168 Frequency suggestion: nightly
169
170 .. _long-overdues-label:
171
172 Long Overdues
173 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
174
175 Script path: misc/cronjobs/longoverdue.pl
176
177 Does: allows one to specify delays for changing items to different lost
178 statuses, and optionally charge for them using the replacement price
179 listed on the item record.
180
181 Frequency suggestion: nightly
182
183     **Note**
184
185     Staff can control some of the parameters for the longoverdue cron
186     job with the
187     :ref:`DefaultLongOverdueLostValue <defaultlongoverduelostvalue-&-defaultlongoverduedays-label>` and
188     :ref:`DefaultLongOverdueChargeValue`
189     preferences.
190
191 .. _track-total-checkouts-label:
192
193 Track Total Checkouts
194 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
195
196 Script path: misc/cronjobs/update\_totalissues.pl
197
198 Does: updates the biblioitems.totalissues field in the database with the
199 latest tally of checkouts based on historical issue statistics.
200
201 Frequency suggestion: nightly
202
203     **Warning**
204
205     If the time on your database server does not match the time on your Koha
206     server you will need to take that into account, and probably use the
207     --since argument instead of the --interval argument for incremental
208     updating.
209
210     **Note**
211
212     This cronjob can be used if there is a performance concern. Otherwise,
213     use the UpdateTotalIssuesOnCirc System Preference.
214
215 .. _generate-patron-file-for-offline-circulation-label:
216
217 Generate Patron File for Offline Circulation
218 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
219
220 Script path: misc/cronjobs/create\_koc\_db.pl
221
222 Does: Generates the borrowers.db file for use with the :ref:`Koha Offline
223 Circulation <offline-circ-tool-for-windows-label>` tool
224
225 Frequency suggestion: weekly
226
227 .. _automatic-renewal-label:
228
229 Automatic renewal
230 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
231
232 Script path: misc/cronjobs/automatic\_renewals.pl
233
234 Does: Will automatically renew items if you're allowing automatic
235 renewal with your :ref:`circulation and fine rules <circulation-and-fine-rules-label>`.
236
237 Frequency suggestion: nightly
238
239 .. _patrons-label:
240
241 Patrons
242 ~~~~~~~~~~~~~~~~~~~~~~~~~~
243
244 .. _unverified-registrations-label:
245
246 Unverified Registrations
247 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
248
249 Script path: misc/cronjobs/delete\_expired\_opac\_registrations.pl
250
251 Does: Deletes patron registrations that were submitted via the OPAC but
252 not reviewed by the library within the number of days entered in the
253 :ref:`PatronSelfRegistrationExpireTemporaryAccountsDelay`
254 preference.
255
256 Frequency suggestion: nightly
257
258 .. _unconfirmed-registrations-label:
259
260 Unconfirmed Registrations
261 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
262
263 Script path: misc/cronjobs/delete\_unverified\_opac\_registrations.pl
264
265 Does: Deletes patron self registrations that were submitted via the OPAC
266 but not confirmed via email within 24 hours. This is only necessary if
267 you are requiring patrons to confirm their registrations via email with
268 the
269 :ref:`PatronSelfRegistrationVerifyByEmail`
270 preference.
271
272 Frequency suggestion: hourly
273
274 .. _anonymize-patron-data-label:
275
276 Anonymize Patron Data
277 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
278
279 Script path: misc/cronjobs/batch\_anonymise.pl
280
281 Does: Used to anonymize patron data. This will remove borrowernumbers
282 from circulation history so that the stats are kept, but the patron
283 information is removed for privacy reasons.
284
285 .. _update-child-to-adult-patron-type-label:
286
287 Update Child to Adult Patron Type
288 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
289
290 Script path: misc/cronjobs/j2a.pl
291
292 Does: Convert juvenile/child patrons from juvenile patron category and
293 category code to corresponding adult patron category and category code
294 when they reach the upper age limit defined in the Patron Categories.
295
296 Frequency suggestion: nightly
297
298     **DESCRIPTION**
299     
300     This script is designed to update patrons from juvenile to adult patron
301     types, remove the guarantor, and update their category codes
302     appropriately when they reach the upper age limit defined in the Patron
303     Categories.
304
305     **USAGE EXAMPLES**
306     
307     "juv2adult.pl"
308     
309     "juv2adult.pl" -b=<branchcode> -f=<categorycode> -t=<categorycode> 
310     (Processes a single branch, and updates the patron categories from
311     category to category)
312     
313     "juv2adult.pl" -f=<categorycode> -t=<categorycode> -v -n (Processes all
314     branches, shows all messages, and reports the patrons who would be
315     affected. Takes no action on the database)
316
317 .. _notices-label:
318
319 Notices
320 ~~~~~~~~~~~~~~~~~~~~~~~~~~
321
322 .. _message-queue-label:
323
324 Message Queue
325 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
326
327 Script path: misc/cronjobs/process\_message\_queue.pl
328
329 Does: processes the message queue to send the check out, check in and
330 hold filled emails and SMS message to users and sends outgoing emails to
331 patrons. requires
332 :ref:`EnhancedMessagingPreferences` to be
333 on
334
335 Frequency suggestion: 1-4 hours
336
337     **Important**
338
339     Item due and Advanced due notices are controlled by the
340     :ref:`advance\_notices cron <advanced-notice-label>`.
341
342 .. _advanced-notice-label:
343
344 Advanced Notice
345 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
346
347 Script path: misc/cronjobs/advance\_notices.pl
348
349 Does: prepares "pre-due" notices and "item due" notices for patrons who
350 request them prepares notices for patrons for items just due or coming
351 due soon. requires
352 :ref:`EnhancedMessagingPreferences` to be
353 on
354
355 Frequency suggestion: nightly
356
357     **Note**
358
359     This script does not actually send the notices. It queues them in
360     the :ref:`message queue <message-queue-label>` for later
361
362 .. _overdue-notice-label:
363
364 Overdue Notice
365 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
366
367 Script path: misc/cronjobs/overdue\_notices.pl
368
369 Does: prepares messages to alert patrons of overdue messages (both via
370 email and print)
371
372 Frequency suggestion: nightly
373
374     **Note**
375
376     This script does not actually send the notices. It queues them in
377     the :ref:`message queue <message-queue-label>` for later or generates the
378     HTML for later printing
379
380     **See also**
381     
382     The misc/cronjobs/advance\_notices.pl program allows you to send
383     messages to patrons in advance of their items becoming due, or to alert
384     them of items that have just become due.
385
386 .. _print-hold-notices-label:
387
388 Print Hold Notices
389 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
390
391 Script path: misc/cronjobs/gather\_print\_notices.pl
392
393 Does: looks through the message queue for hold notices that didn't go
394 through because the patron didn't have an email address and generates a
395 print notice
396
397 Frequency suggestion: nightly
398
399 .. _talking-tech-label:
400
401 Talking Tech
402 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
403
404 To learn more about setting up this third party product view the
405 `Talking Tech Appendix <#talkingtechappendix>`__.
406
407 .. _sending-notices-file-label:
408
409 Sending Notices File
410 '''''''''''''''''''''''''''''''''''''''''''''''
411
412 Script path: misc/cronjobs/thirdparty/TalkingTech\_itiva\_outbound.pl
413
414 Does: Script to generate Spec C outbound notifications file for Talking
415 Tech i-tiva phone notification system.
416
417 Required by:
418 :ref:`TalkingTechItivaPhoneNotification`
419
420 Frequency suggestion: nightly
421
422 .. _receiving-notices-file-label:
423
424 Receiving Notices File
425 ''''''''''''''''''''''''''''''''''''''''''''''''''''
426
427 Script path: misc/cronjobs/thirdparty/TalkingTech\_itiva\_inbound.pl
428
429 Does: Script to process received Results files for Talking Tech i-tiva
430 phone notification system.
431
432 Required by:
433 :ref:`TalkingTechItivaPhoneNotification`
434
435 Frequency suggestion: nightly
436
437 .. _notify-patrons-of-expiration-label:
438
439 Notify Patrons of Expiration
440 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
441
442 Script path: misc/cronjobs/membership\_expiry.pl
443
444 Does: Sends messages to warn patrons of their card expiration to the
445 :ref:`messaage queue <message-queue-label>` cron.
446
447 Requires: :ref:`MembershipExpiryDaysNotice`
448
449 Frequency: nightly
450
451 .. _in-processing/book-cart-label:
452
453 In Processing/Book Cart
454 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
455
456 Script path: misc/cronjobs/cart\_to\_shelf.pl
457
458 Does: Updates all items with a location of CART to the item's permanent
459 location.
460
461 Required by: :ref:`NewItemsDefaultLocation`,
462 :ref:`InProcessingToShelvingCart`, &
463 :ref:`ReturnToShelvingCart` system preferences
464
465 Frequency suggestion: hourly
466
467 .. _catalog-label:
468
469 Catalog
470 ~~~~~~~~~~~~~~~~~~~~~~~~~~
471
472 .. _delete-items-label:
473
474 Batch Item Deletion
475 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
476
477 Script path: misc/cronjobs/delete\_items.pl
478
479 Does: A batch item deletion tool, which generates a query against the items
480 database and deletes the items matching the criteria specified in the
481 command line arguments.
482
483 .. _check-url-quick-label:
484
485 Check URL Quick
486 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
487
488 Script path: misc/cronjobs/check-url-quick.pl
489
490 Does: Check URLs from biblio records.
491
492     **Note**
493     
494     This script replaces the check-url.pl script
495
496 .. _check-urls-label:
497
498 Check URLs
499 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
500
501 Script path: misc/cronjobs/check-url.pl
502
503 Does: checks URLs in 856$u field. Script output can now be formatted in
504 CSV or HTML. The HTML version links directly to MARC biblio record
505 editor.
506
507 Frequency suggestion: monthly
508
509 Learn more: http://wiki.koha-community.org/wiki/Check-url_enhancements
510
511 .. _update-authorities-label:
512
513 Update Authorities
514 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
515
516 Script path: misc/migration\_tools/merge\_authority.pl
517
518 Does: Updates biblio data with changes to authorities records
519
520     **Note**
521
522     The name of this script is misleading. This script does not merge
523     authorities together it instead merges authority data with linked
524     bib records. Edits to authority records will be applied to
525     bibliographic records that use that authority when this script is
526     run.
527
528 Required by: `dontmerge <#dontmerge>`__ system preference
529
530 Frequency suggestion: nightly
531
532 .. _serials-update-label:
533
534 Serials Update
535 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
536
537 Script path: misc/cronjobs/serialsUpdate.pl
538
539 Does: checks if there is a "late" issue on active subscriptions, and if
540 there is, the script will set it as late, and add the next one as
541 expected.
542
543 Frequency suggestion: nightly
544
545 .. _automatic-item-update-label:
546
547 Automatic item update
548 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
549
550 Script path: misc/cronjobs/automatic\_item\_modification\_by\_age.pl
551
552 Does: updates items based on the list of rules set forth in the
553 :ref:`Automatic item modifications by age` tool
554
555 Required by: :ref:`Automatic item modifications by age`
556
557 Frequency suggestions: nightly
558
559 .. _opac-label:
560
561 OPAC
562 ~~~~~~~~~~~~~~~~~~~~~
563
564 .. _rss-feeds-label:
565
566 RSS Feeds
567 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
568
569 Script path: misc/cronjobs/rss/rss.pl
570
571 Does: Produces an RSS XML document for any SQL query (not used for
572 search results RSS feed). :ref:`Learn more <custom-rss-feeds-label>`.
573
574 Frequency suggestion: hourly
575
576 .. _authorities-browser-label:
577
578 Authorities Browser
579 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
580
581 Script path: misc/cronjobs/build\_browser\_and\_cloud.pl
582
583 Does: Generate content for authorities browse in OPAC
584
585 Required by: :ref:`OpacBrowser` system preference
586
587     **Important**
588
589     This preference and cron job should only be used on French systems.
590
591 .. _subject/author-clouds-label:
592
593 Subject/Author Clouds
594 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
595
596 Script path: misc/cronjobs/cloud-kw.pl
597
598 Does: Generates HTML keywords clouds from Koha Zebra indexes.
599 misc/cronjobs/cloud-sample.conf has a sample of how this script
600 operates.
601
602 Frequency: This is the type of script you can run once a month or so,
603 the content generated isn't going to change very much over time.
604
605 .. _system-administration-label:
606
607 System Administration
608 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
609
610 .. _clean-up-database-label:
611
612 Clean up Database
613 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
614
615 Script path: misc/cronjobs/cleanup\_database.pl
616
617 Does: Truncates the sessions table, cleans out old zebraqueue entries,
618 action logs and staged MARC files.
619
620 .. _share-usage-stats-label:
621
622 Share Usage Stats
623 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
624
625 Script path: misc/cronjobs/share\_usage\_with\_koha\_community.pl
626
627 Does: If you're sharing information via the :ref:`UsageStats`
628 feature this will send your info to the `Hea
629 website <http://hea.koha-community.org/>`__.
630
631 Frequency: monthly
632
633 .. _acquisitions-label:
634
635 Acquisitions
636 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
637
638 .. _clean-up-old-suggestions-label:
639
640 Clean up old suggestions
641 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
642
643 Script path: misc/cronjobs/purge\_suggestions.pl
644
645 Does: Removes old (defined by you) suggestions from the suggestion
646 management area.
647
648 .. _email-suggestions-to-process-label:
649
650 Email suggestions to process
651 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
652
653 Script path: misc/cronjobs/notice\_unprocessed\_suggestions.pl
654
655 Does: Generates a notice to the fund owner that there are suggestions in
656 need of processing
657
658 .. _edi-message-processing-label:
659
660 EDI Message Processing
661 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
662
663 Script path: misc/cronjobs/edi\_cron.pl
664
665 Does: Sends and received EDI messages
666
667 Frequency: Every 15 minutes
668
669 .. _deprecated-scripts-label:
670
671 Deprecated scripts
672 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
673
674 These should not be run without modification:
675
676 Script path: misc/cronjobs/update\_items.pl
677
678 Script path:misc/cronjobs/smsoverdues.pl
679
680 Script path:misc/cronjobs/notifyMailsOp.pl
681
682 Script path:misc/cronjobs/reservefix.pl
683
684 Script path:misc/cronjobs/zebraqueue\_start.pl