Added: delete_patrons.pl, delete_records_via_leader.pl
[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 .. _delete-patrons-label:
245
246 Batch Delete Patrons
247 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
248
249 Script path: misc/cronjobs/delete\_patrons.pl
250
251 Does: Deletes patron records in batch based on date not borrowed since,
252 expired before, last seen, category code, or library branch.
253
254 .. _unverified-registrations-label:
255
256 Unverified Registrations
257 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
258
259 Script path: misc/cronjobs/delete\_expired\_opac\_registrations.pl
260
261 Does: Deletes patron registrations that were submitted via the OPAC but
262 not reviewed by the library within the number of days entered in the
263 :ref:`PatronSelfRegistrationExpireTemporaryAccountsDelay`
264 preference.
265
266 Frequency suggestion: nightly
267
268 .. _unconfirmed-registrations-label:
269
270 Unconfirmed Registrations
271 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
272
273 Script path: misc/cronjobs/delete\_unverified\_opac\_registrations.pl
274
275 Does: Deletes patron self registrations that were submitted via the OPAC
276 but not confirmed via email within 24 hours. This is only necessary if
277 you are requiring patrons to confirm their registrations via email with
278 the
279 :ref:`PatronSelfRegistrationVerifyByEmail`
280 preference.
281
282 Frequency suggestion: hourly
283
284 .. _anonymize-patron-data-label:
285
286 Anonymize Patron Data
287 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
288
289 Script path: misc/cronjobs/batch\_anonymise.pl
290
291 Does: Used to anonymize patron data. This will remove borrowernumbers
292 from circulation history so that the stats are kept, but the patron
293 information is removed for privacy reasons.
294
295 .. _update-child-to-adult-patron-type-label:
296
297 Update Child to Adult Patron Type
298 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
299
300 Script path: misc/cronjobs/j2a.pl
301
302 Does: Convert juvenile/child patrons from juvenile patron category and
303 category code to corresponding adult patron category and category code
304 when they reach the upper age limit defined in the Patron Categories.
305
306 Frequency suggestion: nightly
307
308     **DESCRIPTION**
309     
310     This script is designed to update patrons from juvenile to adult patron
311     types, remove the guarantor, and update their category codes
312     appropriately when they reach the upper age limit defined in the Patron
313     Categories.
314
315     **USAGE EXAMPLES**
316     
317     "juv2adult.pl"
318     
319     "juv2adult.pl" -b=<branchcode> -f=<categorycode> -t=<categorycode> 
320     (Processes a single branch, and updates the patron categories from
321     category to category)
322     
323     "juv2adult.pl" -f=<categorycode> -t=<categorycode> -v -n (Processes all
324     branches, shows all messages, and reports the patrons who would be
325     affected. Takes no action on the database)
326
327 .. _notices-label:
328
329 Notices
330 ~~~~~~~~~~~~~~~~~~~~~~~~~~
331
332 .. _message-queue-label:
333
334 Message Queue
335 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
336
337 Script path: misc/cronjobs/process\_message\_queue.pl
338
339 Does: processes the message queue to send the check out, check in and
340 hold filled emails and SMS message to users and sends outgoing emails to
341 patrons. requires
342 :ref:`EnhancedMessagingPreferences` to be
343 on
344
345 Frequency suggestion: 1-4 hours
346
347     **Important**
348
349     Item due and Advanced due notices are controlled by the
350     :ref:`advance\_notices cron <advanced-notice-label>`.
351
352 .. _advanced-notice-label:
353
354 Advanced Notice
355 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
356
357 Script path: misc/cronjobs/advance\_notices.pl
358
359 Does: prepares "pre-due" notices and "item due" notices for patrons who
360 request them prepares notices for patrons for items just due or coming
361 due soon. requires
362 :ref:`EnhancedMessagingPreferences` to be
363 on
364
365 Frequency suggestion: nightly
366
367     **Note**
368
369     This script does not actually send the notices. It queues them in
370     the :ref:`message queue <message-queue-label>` for later
371
372 .. _overdue-notice-label:
373
374 Overdue Notice
375 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
376
377 Script path: misc/cronjobs/overdue\_notices.pl
378
379 Does: prepares messages to alert patrons of overdue messages (both via
380 email and print)
381
382 Frequency suggestion: nightly
383
384     **Note**
385
386     This script does not actually send the notices. It queues them in
387     the :ref:`message queue <message-queue-label>` for later or generates the
388     HTML for later printing
389
390     **See also**
391     
392     The misc/cronjobs/advance\_notices.pl program allows you to send
393     messages to patrons in advance of their items becoming due, or to alert
394     them of items that have just become due.
395
396 .. _print-hold-notices-label:
397
398 Print Hold Notices
399 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
400
401 Script path: misc/cronjobs/gather\_print\_notices.pl
402
403 Does: looks through the message queue for hold notices that didn't go
404 through because the patron didn't have an email address and generates a
405 print notice
406
407 Frequency suggestion: nightly
408
409 .. _talking-tech-label:
410
411 Talking Tech
412 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
413
414 To learn more about setting up this third party product view the
415 `Talking Tech Appendix <#talkingtechappendix>`__.
416
417 .. _sending-notices-file-label:
418
419 Sending Notices File
420 '''''''''''''''''''''''''''''''''''''''''''''''
421
422 Script path: misc/cronjobs/thirdparty/TalkingTech\_itiva\_outbound.pl
423
424 Does: Script to generate Spec C outbound notifications file for Talking
425 Tech i-tiva phone notification system.
426
427 Required by:
428 :ref:`TalkingTechItivaPhoneNotification`
429
430 Frequency suggestion: nightly
431
432 .. _receiving-notices-file-label:
433
434 Receiving Notices File
435 ''''''''''''''''''''''''''''''''''''''''''''''''''''
436
437 Script path: misc/cronjobs/thirdparty/TalkingTech\_itiva\_inbound.pl
438
439 Does: Script to process received Results files for Talking Tech i-tiva
440 phone notification system.
441
442 Required by:
443 :ref:`TalkingTechItivaPhoneNotification`
444
445 Frequency suggestion: nightly
446
447 .. _notify-patrons-of-expiration-label:
448
449 Notify Patrons of Expiration
450 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
451
452 Script path: misc/cronjobs/membership\_expiry.pl
453
454 Does: Sends messages to warn patrons of their card expiration to the
455 :ref:`messaage queue <message-queue-label>` cron.
456
457 Requires: :ref:`MembershipExpiryDaysNotice`
458
459 Frequency: nightly
460
461 .. _in-processing/book-cart-label:
462
463 In Processing/Book Cart
464 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
465
466 Script path: misc/cronjobs/cart\_to\_shelf.pl
467
468 Does: Updates all items with a location of CART to the item's permanent
469 location.
470
471 Required by: :ref:`NewItemsDefaultLocation`,
472 :ref:`InProcessingToShelvingCart`, &
473 :ref:`ReturnToShelvingCart` system preferences
474
475 Frequency suggestion: hourly
476
477 .. _catalog-label:
478
479 Catalog
480 ~~~~~~~~~~~~~~~~~~~~~~~~~~
481
482 .. _delete-items-label:
483
484 Batch Item Deletion
485 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
486
487 Script path: misc/cronjobs/delete\_items.pl
488
489 Does: A batch item deletion tool, which generates a query against the items
490 database and deletes the items matching the criteria specified in the
491 command line arguments.
492
493 .. _check-url-quick-label:
494
495 Check URL Quick
496 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
497
498 Script path: misc/cronjobs/check-url-quick.pl
499
500 Does: Check URLs from biblio records.
501
502     **Note**
503     
504     This script replaces the check-url.pl script
505
506 .. _check-urls-label:
507
508 Check URLs
509 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
510
511 Script path: misc/cronjobs/check-url.pl
512
513 Does: checks URLs in 856$u field. Script output can now be formatted in
514 CSV or HTML. The HTML version links directly to MARC biblio record
515 editor.
516
517 Frequency suggestion: monthly
518
519 Learn more: http://wiki.koha-community.org/wiki/Check-url_enhancements
520
521 .. _delete-records-via-leader-label:
522
523 Delete Records via Leader
524 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
525
526 Script path: misc/cronjobs/delete\_records\_via\_leader.pl
527
528 Does: Attempt to delete any MARC records where the leader character 5 equals 'd'
529
530 .. _update-authorities-label:
531
532 Update Authorities
533 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
534
535 Script path: misc/migration\_tools/merge\_authority.pl
536
537 Does: Updates biblio data with changes to authorities records
538
539     **Note**
540
541     The name of this script is misleading. This script does not merge
542     authorities together it instead merges authority data with linked
543     bib records. Edits to authority records will be applied to
544     bibliographic records that use that authority when this script is
545     run.
546
547 Required by: `dontmerge <#dontmerge>`__ system preference
548
549 Frequency suggestion: nightly
550
551 .. _serials-update-label:
552
553 Serials Update
554 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
555
556 Script path: misc/cronjobs/serialsUpdate.pl
557
558 Does: checks if there is a "late" issue on active subscriptions, and if
559 there is, the script will set it as late, and add the next one as
560 expected.
561
562 Frequency suggestion: nightly
563
564 .. _automatic-item-update-label:
565
566 Automatic item update
567 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
568
569 Script path: misc/cronjobs/automatic\_item\_modification\_by\_age.pl
570
571 Does: updates items based on the list of rules set forth in the
572 :ref:`Automatic item modifications by age` tool
573
574 Required by: :ref:`Automatic item modifications by age`
575
576 Frequency suggestions: nightly
577
578 .. _opac-label:
579
580 OPAC
581 ~~~~~~~~~~~~~~~~~~~~~
582
583 .. _rss-feeds-label:
584
585 RSS Feeds
586 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
587
588 Script path: misc/cronjobs/rss/rss.pl
589
590 Does: Produces an RSS XML document for any SQL query (not used for
591 search results RSS feed). :ref:`Learn more <custom-rss-feeds-label>`.
592
593 Frequency suggestion: hourly
594
595 .. _authorities-browser-label:
596
597 Authorities Browser
598 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
599
600 Script path: misc/cronjobs/build\_browser\_and\_cloud.pl
601
602 Does: Generate content for authorities browse in OPAC
603
604 Required by: :ref:`OpacBrowser` system preference
605
606     **Important**
607
608     This preference and cron job should only be used on French systems.
609
610 .. _subject/author-clouds-label:
611
612 Subject/Author Clouds
613 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
614
615 Script path: misc/cronjobs/cloud-kw.pl
616
617 Does: Generates HTML keywords clouds from Koha Zebra indexes.
618 misc/cronjobs/cloud-sample.conf has a sample of how this script
619 operates.
620
621 Frequency: This is the type of script you can run once a month or so,
622 the content generated isn't going to change very much over time.
623
624 .. _system-administration-label:
625
626 System Administration
627 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
628
629 .. _clean-up-database-label:
630
631 Clean up Database
632 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
633
634 Script path: misc/cronjobs/cleanup\_database.pl
635
636 Does: Truncates the sessions table, cleans out old zebraqueue entries,
637 action logs and staged MARC files.
638
639 .. _share-usage-stats-label:
640
641 Share Usage Stats
642 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
643
644 Script path: misc/cronjobs/share\_usage\_with\_koha\_community.pl
645
646 Does: If you're sharing information via the :ref:`UsageStats`
647 feature this will send your info to the `Hea
648 website <http://hea.koha-community.org/>`__.
649
650 Frequency: monthly
651
652 .. _acquisitions-label:
653
654 Acquisitions
655 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
656
657 .. _clean-up-old-suggestions-label:
658
659 Clean up old suggestions
660 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
661
662 Script path: misc/cronjobs/purge\_suggestions.pl
663
664 Does: Removes old (defined by you) suggestions from the suggestion
665 management area.
666
667 .. _email-suggestions-to-process-label:
668
669 Email suggestions to process
670 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
671
672 Script path: misc/cronjobs/notice\_unprocessed\_suggestions.pl
673
674 Does: Generates a notice to the fund owner that there are suggestions in
675 need of processing
676
677 .. _edi-message-processing-label:
678
679 EDI Message Processing
680 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
681
682 Script path: misc/cronjobs/edi\_cron.pl
683
684 Does: Sends and received EDI messages
685
686 Frequency: Every 15 minutes
687
688 .. _deprecated-scripts-label:
689
690 Deprecated scripts
691 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
692
693 These should not be run without modification:
694
695 Script path: misc/cronjobs/update\_items.pl
696
697 Script path:misc/cronjobs/smsoverdues.pl
698
699 Script path:misc/cronjobs/notifyMailsOp.pl
700
701 Script path:misc/cronjobs/reservefix.pl
702
703 Script path:misc/cronjobs/zebraqueue\_start.pl