工作排程與守護行程

Koha is supported by a number of background tasks. These tasks can either be periodically executed tasks (cron jobs) or continuously running tasks called daemons.

工作排程是安排自動伺服器裡的指令或腳本以完成指定工作的 Linux 指令。以工作排程方式執行的腳本通常是修改檔案或資料庫;然而,它們也可以執行其他不需修改伺服器資料的工作,像是送出電子郵件通知。

daemon 是 Linux 命令,系統啟動後就開始執行,並持續在背景執行若干功能。Koha 用到的資料庫 (MYSQL 或 MariaDB) 及網頁伺服器 (通常是 Apache),就是一種 daemon。

Koha has many cron jobs in place that you can enable (search engine indexing, overdue notice generation, data cleanup and more), and a few daemons. This chapter will explain those for you.

Crontab 範例

Koha crontab 在 misc/cronjobs/crontab.example

此範例包括 boilerplate 工作排程款目的樣本。

工作排程

The locations in the documentation assume a development install where files are found in misc/ relative to the git root checkout. If you have installed using Debian packages or the standard install from source, you will want to look for files in /usr/share/koha/bin/.

Other locations are possible with other installation methods. You can perform a simple find search if they are not located in these directories.

備註

For anyone with shell access using Debian packages, the following command is an easy way to find files installed by a Debian package:

dpkg -L koha-common

This provides a comprehensive listing of the files installed by the koha-common package. You can then easily find the file from there.

備份

每日備份

腳本路徑:misc/cronjobs/backup.sh

做:新增 Koha 資料庫逐日備份。

刊期建議:日刊

流通

預約佇列

腳本路徑:misc/cronjobs/holds/build_holds_queue.pl

做:更新預約順位報表

必須用到:預約順位報表

建議頻率:每 1-4 小時

說明:

  • 應定期執行腳本若您的圖書館系統允許讀者預約在架的館藏。此腳本決定負責滿足此預約的圖書館。

    由系統偏好 StaticHoldsQueueWeightRandomizeHoldsQueueWeight 共同控制其行為。

    不讓所有圖書館參與館藏滿足預約計畫,應列出*要*參加該計畫的圖書館,包括圖書館的條碼,並以逗點區隔(如:」MPL,CPL,SPL,BML」 等)。

    預設,預約順位將先列入提取圖書館。若無法滿足,則 build_holds_queue.pl 將取用 StaticHoldsQueueWeight 設定的圖書館。若停用 RandomizeHoldsQueueWeight (預設值為停用),則依 StaticHoldsQueueWeight 偏好設定的圖書館順序,逐一取用。

    例如,系統內有三個規模不一的圖書館(大型、中型與小型),希望由大型圖書館承擔較多的預約責任,StaticHoldsQueueWeight偏好應設為」LRG,MED,SML」。

    若期望各圖書館平均分擔預約的任務,應啟用RandomizeHoldsQueueWeight偏好,將隨機將預約分配給各圖書館。

預約過期

腳本路徑:misc/cronjobs/holds/cancel_expired_holds.pl

Does: cancels holds where the user has set an expiration date. If the library is using the ExpireReservesMaxPickUpDelay and ExpireReservesMaxPickUpDelayCharge preferences then this script will also cancel holds that have been sitting on the hold shelf for too long and will (if the library does) charge the patron for not picking up the hold.

可以使用 –原因參數增加取消原因。使用 HOLD_CANCELLATION 權威值類型 中取消代碼

刊期建議:日刊

取消預約

腳本路徑:misc/cronjobs/holds/auto_unsuspend_holds.pl

Does: checks to find holds that should no longer be suspended and removes the suspension if the AutoResumeSuspendedHolds preference is set to 『allow』. This puts the patron back in to the queue where they were when the hold was suspended.

刊期建議:日刊

罰款

腳本路徑:misc/cronjobs/fines.pl

做: 計算和收取(或遞增)逾期罰款每館藏對讀者帳號。罰款計算使用寬限期已處理,罰款間隔, 罰款總數和其它參數從:ref:circulation and fines rules <circulation-and-fines-rules-label>.

Required by: finesMode system preference

建議頻率:每晚

說明 若 Koha 系統偏好 『finesMode』 已設為 『production』,則向讀者收取罰款。若設為 『test』,則計算罰款但不收取。

說明 假日不計入罰款。

參數 - -h|–help

  • 取得協助資訊

  • -l|–log

    • 記錄匯出至檔案 (如果提供 -o 參數)

  • -o|–out

    • 為記錄匯出資料夾 (預設是 env 或 /tmp 如果資料夾不存在)

  • -v|–verbose

    • verbose 模式

  • -m|–maxdays

    • 逾期多少天來處理

    • 這可以透過簡單地處理的記錄數量來提高性能。考慮到流通政策通常會在幾天後將罰款限制在最高限額,因此將處理的逾期款項限制在逾期 X 天以內是安全的。

固定罰款

腳本路徑:misc/cronjobs/staticfines.pl

做: 針對目前未付的讀者對任何/所有逾期收取單獨一定的罰款.費用由讀者類型每指令行定義或將使用流通規則針對讀者未付的最長逾期館藏(只針對第一個罰款期間)。一旦收費,罰款是定額: 沒有新罰款會再加入直到現有罰款已完全付清。

建議頻率:每晚

說明 若 Koha 系統偏好 『finesMode』 已設為 『production』,則向讀者收取罰款。若設為 『test』,則計算罰款但不收取。

說明 假日不計入罰款。

Batch writeoff charges

Script path: misc/cronjobs/writeoff_debts.pl

Does: writes off outstanding charges in patron accounts.

參數

備註

The options to select the debt records to writeoff are cumulative. For example, supplying both --added_before and --type specifies that the accountline must meet both conditions to be selected for writeoff.

備註

You must use at least one of the filtering options for the script to run. This is to prevent an accidental 『writeoff all』 operation.

  • -h | --help

    • Displays help message.

  • -v | --verbose

    • Verbose output.

  • --added-before

    • Write off charges added before the specified date.

    • Dates should be in ISO format, e.g., 2013-07-19, and can be generated with date -d '-3 month' --iso-8601.

  • --added-after

    • Write off charges added after the specified date.

    • Dates should be in ISO format, e.g., 2013-07-19, and can be generated with date -d '-3 month' --iso-8601.

    版本

    The --added-after parameter was added in Koha version 23.11.

  • --category-code

    • Write off charges of patrons belonging to the specified categories.

    • Repeatable.

    版本

    The --category-code parameter was added in Koha version 23.11.

  • --type

  • --file

    • Write off charges passed as one accountlines_id per line in this file.

    • If other criteria are defined it will only writeoff those in the file that match those criteria.

  • --confirm

    • This parameter is needed to actually writeoff the charges.

    • Running the script without this parameter will only output which charges would have been written off.

USAGE EXAMPLES

writeoff_debts.pl --added_after 2023-06-20 --confirm

Will write off charges added after 2023-06-20.

writeoff_debts.pl --added_before `date -d '-3 month' --iso-8601` --category-code K --confirm

Will write off charges older than 3 months for patrons in the 『K』 category.

逾期太久

腳本路徑:misc/cronjobs/longoverdue.pl

做:允許更改不同程度的遺失館藏,並向讀者收取館藏記錄內的重置價格。

建議頻率:每晚

說明

Staff can control some of the parameters for the longoverdue cron job with the DefaultLongOverdueLostValue and DefaultLongOverdueChargeValue preferences.

追蹤借出總數

腳本路徑:misc/cronjobs/update_totalissues.pl

做:以最新的借出現況更新資料庫內 biblioitems.totalissues 欄位的內容。

建議頻率:每晚

警示

需考量資料庫伺服器與 Koha 伺服器的時間不同步的狀況,並使用 –since 參數取代 –interval 參數做為新增性更新的依據。

說明

This cronjob can be used if there is a performance concern. Otherwise, use the UpdateTotalIssuesOnCirc System preference.

產生讀者檔供離線流通之用

腳本路徑:misc/cronjobs/create_koc_db.pl

做:從 Koha 離線流通 工具產生 borrowers.db 檔案

建議頻率:每週

自動續借

腳本路徑:misc/cronjobs/automatic_renewals.pl

做:若在 流通與罰款規則 裡允許自動續借,將自動續借。

建議頻率:每晚

重要

為了正確執行,您必須使用 –confirm 參數, 否則它會在測試模式下執行

參數 - -h|–help

  • 取得協助資訊

  • –發送-通知

    • 如果執行了自動續借,寄送 AUTO_RENEWALS 通知給讀者

  • -v|–verbose

    • verbose 模式

  • -c|–confirm

    • 若沒有此參數則不會進行任何更改,腳本將以測試模式執行

    • 若沒有此參數,腳本也將預設為詳細模式

自動還入

腳本路徑:misc/cronjobs/automatic_checkin.pl

做:在借出期限後自動檢查館藏。這是在 :ref:`館藏類型級別<item-types-label>`設定的。

建議頻率:每晚

催還

到期催還

腳本路徑:misc/cronjobs/recalls/expire_recalls.pl

做:自動標記為逾期催還

  • 已被要求,但尚未履行且已逾期

  • recalls that have been awaiting pickup longer than the pickup period in the circulation rules or the period set in the RecallsMaxPickUpDelay system preference

建議頻率:每晚

逾期催還

腳本路徑:misc/cronjobs/recalls/overdue_recalls.pl

做:如果未在調整後的到期日歸還,則會將催還的館藏設定為逾期

建議頻率:每晚

讀者

批次刪除讀者

腳本路徑:misc/cronjobs/delete_patrons.pl

做:依照未曾借出日期、到期日、上網日期、屬性、或所屬圖書館,批次刪除讀者紀錄。

說明

應採用 ISO 格式的日期,如 2013-07-19,可以用指令產生 date -d 『-3 month』 「+%Y-%m-%d」。

重要

此選項是選擇讀者記錄去刪除 累積的。比方說,供應同為 –expired_before 以及 –library 指定特定讀者記錄必須吻合 同時 選擇刪除為條件。

參數

  • –not_borrowed_since 刪除到此日未曾借過書過的讀者

    警告

    Patrons who have all their old checkouts anonymized will have an empty circulation history and be deleted if this option is used. Anonymization can happen because the patron has borrowers.privacy = 2, through cronjobs doing anonymization or by the patron choosing to anonymize their history in the OPAC.

  • –expired_before 刪除帳號失效日早過此日的讀者

  • –last_seen Delete patrons who have not been connected since this date. The system preference TrackLastPatronActivity must be enabled to use this option.

  • –category_code 刪除此類讀者類型的讀者

  • –library 刪除此圖書館的讀者

  • -c|–confirm 此旗標心須提供以便程式能實際刪除讀者記錄。如果未提供,程式將呈報它將刪除的讀者記錄

  • -v|–verbose Verbose 模式.

匿名讀者資料

腳本路徑:misc/cronjobs/batch_anonymise.pl

做:用於匿名讀者資料。此腳本將從流通記錄裡移除讀者號,一方面保護讀者的隱私同時又保持原有的流通記錄。

更新讀者目錄

腳本路徑:misc/cronjobs/update_patrons_category.pl

做:將符合條件的讀者的讀者類型更新為另一個指定的讀者類型。當兒童讀者達到 讀者類型 中定義的年齡上限時,這可用於將兒童讀者從兒童讀者類型轉換為成人讀者類型。

此腳本用以重置 j2a.pl script。

建議頻率:每晚

DESCRIPTION

此腳本設計為使用命令行參數指定的標準將讀者從一個類型更新到另一個類型。

參數

  • –too_old 更新,如果讀者超過其當前 讀者類型 的年齡上限。

  • –too_young 更新,如果讀者低於他們 讀者類型 的最低年齡限制。

  • 如果讀者帳號的罰款總額超過 X,–fo=X|–fineover=X 更新。

  • 如果讀者帳號的罰款總額低於 X,–fu=X|–fineunder=X 更新。

  • –rb=date|regbefore=日期更新,如果讀者的註冊日期早於給定日期。

  • –ra=date|regafter=日期更新,如果讀者的註冊日期晚於給定日期。

  • -d –field name=值如果符合給定條件,則更新。 <name> 必須替換為 borrowers 表單的分欄。如果欄位的內容等於 <value>,則符合條件。

  • –where <conditions> 如果符合 SQL <where> 語法,則更新。

  • -v|–verbose 詳細模式:若未有此旗標,只回報嚴重的錯誤。

  • -c|–confirm 送出對資料庫的更改。除非將此參數新增到命令中,否則不會進行任何更改。

  • -b|–branch <branchcode> 更新,如果讀者的所屬圖書館與給定的 <branchcode> 匹配。

  • -f|–form <categorycode> 更新,如果讀者當前有這個讀者類型。

  • -t|–to <categorycode> 將符合條件的讀者更新為該讀者類型。

USAGE EXAMPLES

「update_patrons_category.pl」

「update_patrons_category.pl」 -b=<branchcode> -f=<categorycode> -t=<categorycode> -c」處理單一分館,並逐一更新讀者類型)

「update_patrons_category.pl」 -f=<categorycode> -t=<categorycode> -v」 (處理所有分館、顯示全部訊息、回報受影響的讀者。不更動資料庫)

更新讀者的訊息偏好

腳本路徑:misc/maintenance/borrowers-force-messaging-defaults.pl

做:將讀者的訊息偏好更新為 :ref:`讀者類型<patron-categories-label>`中設定的預設值。

增加新讀者 或當 :ref:`使用讀者匯入工具<patron-import-label> 匯入讀者時,會自動設定預設訊息偏好,但是,如果您直接在資料庫中匯入讀者,則不會設定這些訊息偏好。

沒有建議的頻率。這是一個在需要時使用的工具,如果您經常直接在資料庫中輸入讀者(例如經由第三方),您可以將它增加到您的排程列中。

DESCRIPTION

If the EnhancedMessagingPreferences system preference is enabled after borrowers have been created in the DB, those borrowers won’t have messaging transport preferences default values as defined for their borrower category. So you would have to modify each borrower one by one if you would like to send them 『Hold Filled』 notice for example.

此腳本為所有讀者建立/覆蓋訊息偏好,並將它們設定為為他們所屬類型定義的預設值(除非您使用選項 -not-expired 或 -no-overwrite 來更新子欄位)。

參數

  • --help

    • Display help message.

  • --doit

    • 更新讀者。如果沒有此選項,腳本將不會更新讀者的訊息偏好。它只會列出應更新的讀者。

  • --not-expired

    • 僅更新仍然活躍的讀者(其檔案尚未過期)。

  • --no-overwrite

    • 只更新沒有任何訊息偏好的讀者。此選項將跳過已經設定了偏好的讀者。

  • --category

    • 只更新指定類型的讀者。

    警告

    此選項**不能**重複。

    範例:

    borrowers-force-messaging-defaults.pl --doit --category PT --category B
    

    只會更新類型 B(指定的最後一個類型)的讀者。

  • --library

    • Will only update patrons whose home library matches the given branchcode.

    版本

    The --library parameter was added in Koha version 23.11.

  • --message-name

    • Will only update preferences for the specific message.

    • The list of values can be found in installer/data/mysql/mandatory/sample_notices_message_attributes.sql, in message_attributes.message_name in the database, or in the notices and slips tool.

    版本

    The --message-name parameter was added in Koha version 23.11.

  • --since

    • 僅更新自指定日期以來註冊的讀者。

    備註

    此選項可以使用特定或相對日期。

    範例:

    borrowers-force-messaging-defaults.pl --doit --since "2022-07-12"
    

    只會更新自 2022 年 7 月 12 日以來註冊的讀者。

    和:

    borrowers-force-messaging-defaults.pl --doit --since `date -d "1 day ago" '+%Y-%m-%d'
    

    只會更新自昨天以來註冊的讀者。

USAGE EXAMPLES

borrowers-force-messaging-defaults.pl --doit

更新所有讀者其各自類型的訊息預設偏好值。

borrowers-force-messaging-defaults.pl --doit --not-expired

更新所有會員資格未過期的讀者其各自類型的訊息預設偏好值。

borrowers-force-messaging-defaults.pl --doit --category PT

更新 PT 類型中所有讀者的訊息預設偏好。

borrowers-force-messaging-defaults.pl --doit --no-overwrite --since "2022-03-01"

更新未設定任何訊息偏好且自 2022 年 3 月 1 日起註冊的讀者。

borrowers-force-messaging-defaults.pl --doit --no-overwrite --since `date -d "1 day ago" '+%Y-%m-%d'

Updates patrons who do not have any messaging preferences set and who are enrolled since yesterday.

borrowers-force-messaging-defaults.pl --doit --library CPL

Updates patrons whose home library is CPL.

borrowers-force-messaging-defaults.pl --doit --message-name Item_due

Updates preferences for the 「Item due」 message only.

通知

信件佇列

腳本路徑:misc/cronjobs/process_message_queue.pl

Does: processes the message queue to send outgoing emails and SMS messages to patrons. Messages are queued in the message queue by other scripts, such as advance_notices.pl, overdue_notices.pl, and holds_reminder.pl.

備註

Requires that EnhancedMessagingPreferences be set to 『Allow』.

建議頻率:1-4小時

DESCRIPTION

This script processes the message queue in the message_queue database table. It sends out the messages in that queue and marks them appropriately to indicate success or failure. It is recommended that you run this regularly from cron, especially if you are using the advance_notices.pl script.

參數

  • -u | –username

    • Username of the mail account used to send the notices.

  • -p | –password

    • Password of mail account used to send the notices.

  • -t | –type

    • If supplied, only processes this type of message. Possible values are

      • email

      • sms

    • Repeatable

  • -c | –code

    • If supplied, only processes messages with this letter code.

    • Repeatable.

  • -l | –limit

    • The maximum number of messages to process for this run.

  • -m | –method

    • Authentication method required by SMTP server (see perldoc Sendmail.pm for supported authentication types).

  • -h | –help

    • Help message.

  • -v | –verbose

    • Provides verbose output to STDOUT.

  • -w | –where

    • Filter messages to send with additional conditions in a where clause.

提前通知

腳本路徑:misc/cronjobs/advance_notices.pl

Does: prepares 「pre-due」 notices and 「item due」 notices for patrons who request them prepares notices for patrons for items just due or coming due soon. requires EnhancedMessagingPreferences to be on

建議頻率:每晚

說明

此腳本不會真的送出通知。祗把通知置於 訊息佇列 供以後使用

逾期通知

腳本路徑:Script path: misc/cronjobs/overdue_notices.pl

做:準備讀者逾期的訊息 (經電子郵件或列印)

建議頻率:每晚

DESCRIPTION

This script creates and queues the overdue notices according to the parameters set in the overdue notice/status triggers tool.

參數

  • -n | –nomail

    • Do not send any email. Overdue notices that would have been sent to the patrons or to the admin are printed to standard out. CSV data (if the –csv flag is set) is written to standard out or to any CSV filename given.

  • –max <days>

    • Maximum days overdue to deal with.

    • Items overdue since longer than max days are assumed to be handled somewhere else, probably the longoverdues script. They are therefore ignored by this script. No notices are sent for them, and they are not added to any CSV files.

    • Defaults to 90 days.

  • –library <branchcode>

    • Only deal with overdues from this library.

    • Use the value in the branches.branchcode table.

    • This parameter is repeatable, to process overdues for a group of libraries.

  • –csv <filename>

    • Produces a CSV file.

    • If the -n (no mail) flag is set, this CSV data is sent to standard out or to a filename if provided. Otherwise, only overdues that could not be emailed are sent in CSV format to the admin.

  • –html <directory>

    • Output html to a file in the given directory.

    • If a patron does not have an email address or if the -n (no mail) flag is set, an HTML file is generated in the specified directory. This can be downloaded or further processed by library staff.

    • The file will be called notices-YYYY-MM-DD.html and placed in the directory specified.

  • –text <directory>

    • Output plain text to a file in the given directory.

    • If a patron does not have an email address or if the -n (no mail) flag is set, a text file is generated in the specified directory. This can be downloaded or further processed by library staff.

    • The file will be called notices-YYYY-MM-DD.txt and placed in the directory specified.

  • –itemscontent <list of fields>

    • Item information in templates.

    • Takes a comma separated list of fields that get substituted into templates in places of the <<items.content>> placeholder.

    • Defaults to due date,title,barcode,author

    • Other possible values come from fields in the biblio, items and issues tables.

  • –borcat <categorycode>

    • Prepare only overdue notices for specified patron categories.

    • This parameter is repeatable, to include several patron categories.

    • Use the value in categories.categorycode.

  • –borcatout <categorycode>

    • Do not prepare overdue notices for specified patron categories.

    • This parameter is repeatable, to exclude several patron categories.

    • Use the value in categories.categorycode.

    • t | –triggered

    • This option causes a notice to be generated if and only if an item is overdue by the number of days defined in the overdue notice trigger.

    • By default, a notice is sent each time the script runs, which is suitable for less frequent run cron script, but requires syncing notice triggers with the cron schedule to ensure proper behavior.

    • Add the –triggered option for daily cron, at the risk of no notice being generated if the cron fails to run on time.

  • –test

    • This option makes the script run in test mode.

    • In test mode, the script won’t make any changes on the DB. This is useful for debugging configuration.

  • –list-all

    • By default, <<items.content>> lists only those items that fall in the range of the currently processing notice.

    • Choose –list-all to include all overdue items in the list (limited by the –max setting).

  • –date <yyyy-mm-dd>

    • Emulate overdues run for this date.

  • –email <email_type>

    • Specify the type of email that will be used.

    • Can be 『email』, 『emailpro』 or 『B_email』.

    • This parameter is repeatable.

  • –frombranch

    • Organize and send overdue notices by home library (item-homebranch) or checkout library (item-issuebranch).

    • Defaults to item-issuebranch.

    備註

    This option is only used if the OverdueNoticeFrom system preference is set to 『command-line option』.

USAGE EXAMPLES

「overdue_notices.pl」

(All libraries are processed individually, and notices are prepared for all patrons with overdue items for whom we have email addresses. Messages for those patrons for whom we have no email address are sent in a single attachment to the library administrator’s email address, or to the address in the KohaAdminEmailAddress system preference.)

「overdue_notices.pl -n –csv /tmp/overdues.csv」

(Sends no email and populates /tmp/overdues.csv with information about all overdue items.)

「overdue_notices.pl –library MAIN max 14

(Prepares notices of overdues in the last 2 weeks for the MAIN library.)

備註

This script does not actually send the notices. It queues them in the message queue to be sent later or generates the HTML for printing.

備註

也可以看看:

The misc/cronjobs/advance_notices.pl script allows you to send messages to patrons in advance of their items becoming due, or to alert them of items that have just become due.

The misc/cronjobs/process_message_queue.pl script sends the emails.

Holds reminder

Script path: misc/cronjobs/holds/holds_reminder.pl

Does: prepares reminder messages to be sent to patrons with waiting holds.

EnhancedMessagingPreferences must be set to 『Allow』, and patrons must have requested to have this notice (either through the Messaging tab in their online account in the OPAC, if EnhancedMessagingPreferencesOPAC is set to 『Show』, or in their messaging preferences in the staff interface).

建議頻率:每晚

參數

  • -c | –confirm

    • Confirm flag, no email will be generated if this parameter is not set

  • -date <YYYY-MM-DD>

    • Send notices as would have been sent on a specific date

  • -days <number of days>

    • Number of days the hold has been waiting

    • If this parameter is not set, a notice will be sent to all patrons with waiting holds

    • Optional parameter

  • -holidays

    • Use the calendar exclude holidays from waiting days

  • -lettercode <lettercode>

    • Code of the predefined notice to use

    • Optional parameter, the default is HOLD_REMINDER

  • -library <branchcode>

    • Only deal with holds from this library

    • This flag is repeatable, to select notices for a group of libraries

  • -mtt <message_transport_type>

    • Type of messages to send (email, sms, print)

      • 『email』 and 『sms』 will fall back to 『print』 if the patron does not have an email address/phone number

    • The default is to use the patrons』 messaging preferences for the 『Hold reminder』 notice

    • Passing this parameter will force send even if the patron has not chosen to receive hold reminder notices

    • This can be repeated to send various notices

  • -t | –triggered

    • Include only holds <days> days waiting, and not longer

    • If this is not set, the script will send messages for all holds waiting for equal to or more than <days> days

    • This option is useful if the cron is being run daily to avoid spamming the patrons

    • Optional parameter

  • -v

    • Verbose

    • Without this flag set, only fatal errors are reported.

    • If verbose is set but not confirm, a list of notices that would have been sent to the patrons are printed to standard out

  • -help

    • Brief help message

  • -man

    • Full documentation

    範例

    下列是此程式的範例:

    ::

    holds_reminder.pl -library MAIN -days 14

    prepares notices of holds waiting for 2 weeks for the MAIN library

    ::

    holds_reminder.pl -lettercode LATE_HOLDS -library MAIN -days 14

prepares notices of holds waiting for 2 weeks for the MAIN library, using the 『LATE_HOLDS』 notice template

Talking Tech

設定此第三方產品的詳情參見 Talking Tech

送出通知檔

腳本路徑:misc/cronjobs/thirdparty/TalkingTech_itiva_outbound.pl

做:產生 Spec C 的通知檔案供 Talking Tech i-tiva 電話通知系統。

Required by: TalkingTechItivaPhoneNotification

建議頻率:每晚

收到通知檔案

腳本路徑:misc/cronjobs/thirdparty/TalkingTech_itiva_inbound.pl

做:腳本處理收到來自Talking Tech i-tiva 電話通知系統的結果檔案。

Required by: TalkingTechItivaPhoneNotification

建議頻率:每晚

通知讀者證有效日期

腳本路徑:misc/cronjobs/membership_expiry.pl

Does: sends messages to warn patrons of their card expiration to the message queue cron. Can optionally renew patron accounts as well.

Requires: MembershipExpiryDaysNotice

頻率:每天

參數

  • --man

    • Prints the manual page and exits.

  • --help

    • Prints a brief help message and exits.

  • -v

    • Verbose.

    • Without this flag set, only fatal errors are reported.

  • -n

    • Do not send any email. Membership expiry notices that would have been sent to the patrons are printed to standard out.

  • -c

    • Confirm flag: Add this option. The script will only print a usage statement otherwise.

  • -branch

    • Optional branchcode to restrict the cronjob to that branch.

  • -before

    • Optional parameter to extend the selection with a number of days BEFORE the date set by the MembershipExpiryDaysNotice system preference.

  • -after

    • Optional parameter to extend the selection with a number of days AFTER the date set by the MembershipExpiryDaysNotice system preference.

    • For example, --before 100 --after 100 will notify patrons who have accounts expiring within a date range of 100 days before and 100 days after the MembershipExpiryDaysNotice system preference.

  • -where

    • Use this option to specify a condition. Add 「me」 (alias) followed by the column name from the borrowers table.

    • For example:

      • --where="me.categorycode !='YA'" will notify patrons from categories other than 『YA』

      • --where="me.categorycode = 'S'" will notify patrons from the category 『S』 only

      • --where 'me.lastseen IS NOT NULL' will only notify patrons who have been seen.

  • -letter

    • Optional parameter to use another notice than the default: MEMBERSHIP_EXPIRY

  • -letter_renew

    • Optional parameter to use another renewal notice than the default: MEMBERSHIP_RENEWED

    版本

    The -letter_renew parameter was added in Koha version 23.11.

  • -active

    • Followed by a number of months.

    • Optional parameter to include active patrons only (active within passed number of months).

    • This parameter needs the TrackLastPatronActivityTriggers system preference.

    • Cannot be used with -inactive below, the two parameters are mutually exclusive

    版本

    The -active parameter was added in Koha version 23.11.

  • -inactive

    • Followed by a number of months.

    • Optional parameter to include inactive patrons only (inactive since passed number of months).

    • This parameter needs the TrackLastPatronActivityTriggers system preference.

    • Cannot be used with -active above, the two parameters are mutually exclusive

    版本

    The -inactive parameter was added in Koha version 23.11.

  • -renew

    • Optional parameter to automatically renew patrons instead of sending them an expiry notice.

    • They will be informed by a membership renewal notice (the default MEMBERSHIP_RENEWED or a custom one specified by -letter_renew)

    版本

    The -renew parameter was added in Koha version 23.11.

USAGE EXAMPLES

membership_expiry.pl -c

Will generate MEMBERSHIP_EXPIRY notices for patrons whose membership expires in the number of days set in MembershipExpiryDaysNotice.

membership_expiry.pl -c -renew

Will renew patrons whose membership expires in the number of days set in MembershipExpiryDaysNotice, and generate MEMBERSHIP_RENEWED notices for them.

membership_expiry.pl -c -renew -letter_renew PATRON_RENEWAL

Will renew patrons whose membership expires in the number of days set in MembershipExpiryDaysNotice, and generate the custom 「PATRON_RENEWAL」 notices for them. A 「PATRON_RENEWAL」 notice would have to have been created in the notices and slips tool beforehand.

membership\_expiry.pl -c -before 30

Will generate MEMBERSHIP_EXPIRY notices for patrons whose membership expires 30 days before the number of days set in MembershipExpiryDaysNotice.

membership_expiry.pl -c -renew -active 3

Will renew patrons whose membership expires in the number of days set in MembershipExpiryDaysNotice, and who have been active in the last three months (「activity」 is determined by the TrackLastPatronActivityTriggers system preference), and generate MEMBERSHIP_RENEWED notices for them.

membership_expiry.pl -c -inactive 6 -letter INACTIVE_PATRON

Will generate the custom 「INACTIVE_PATRON」 notices for patrons whose membership expires in the number of days set in MembershipExpiryDaysNotice, and who have been inactive for the last six months (「activity」 is determined by the TrackLastPatronActivityTriggers system preference). An 「INACTIVE_PATRON」 notice would have to have been created in the notices and slips tool beforehand.

處理中/圖書車

腳本路徑:misc/cronjobs/cart_to_shelf.pl

做:以 CART 位置做為館藏永久位置而更新所有館藏。

Required by: NewItemsDefaultLocation, UpdateItemLocationOnCheckin, and UpdateItemLocationOnCheckout system preferences.

建議頻率:每小時

目錄

批次匯入網頁服務

腳本路徑:misc/cronjobs/import_webservice_batch.pl

做:處理批次匯入 『網頁服務』 屬性佇列的工作排程。也可經由 UI 處理批次。

說明

此腳本適用於 OCLC Connexion

Connexion Import Daemon

腳本路徑:misc/bin/connexion_import_daemon.pl

做:daemon 聽取 OCLC Connexion 的請求並回應 OCLC Gateway 規格。讀取 MARC XML 的請求並從組態檔匯入參數轉交給 svc/import_bib

說明

此腳本適用於 OCLC Connexion

批次刪除館藏

腳本路徑:misc/cronjobs/delete_items.pl

Does: generates a query against the items database and deletes the items matching the criteria specified in the command line arguments. A lightweight batch deletion tool for items, suitable for running in a cron job.

參數

  • --help

    • Prints a brief help message.

  • --man

    • Prints the manual, with examples.

  • --verbose

    • Prints the 「WHERE」 clause generated by the collected --where arguments, as well as items affected to Standard Out.

    • The item information printed is

      • itemnumber

      • barcode

      • 標題

  • --where

    • The following argument must be a syntactically valid SQL statement which is part of the WHERE clause querying the items table.

    • Repeatable. If there are multiple --where parameters, they will be joined by AND.

  • --commit

    • No items will be deleted unless this parameter is present.

USAGE EXAMPLES

delete_items.pl --where "items.withdrawn != 0" --where "items.withdrawn_on < $(date --date="13 month ago" --rfc-3339=date)" --commit

This will delete items where the withdrawn status is not zero AND where the withdrawn date is older than 13 months ago.

delete_items.pl --where "itemlost >= '1'" --where "itemlost <='4'" --where "itemlost_on < '2014-04-28'" --commit

This will delete items where the lost status is between 1 and 4 (inclusively) AND that were lost before 2014-04-28.

快速檢查 URL

腳本路徑:misc/cronjobs/check-url-quick.pl

備註

此腳本替換了已棄用的 check-url.pl 腳本

做: 檢查書目記錄中的網址;掃瞄所有書目記錄從856段分欄u發現的網址並且顯示

參數

  • –host=http://default.tld 使用不含URL,即不以 『http:』 開頭的伺服器主機。例如,若 –host=http://www.mylib.com,則當856$u包含 『img/image.jpg』 時,檢查的URL為:http://www.mylib.com/image.jpg

  • –tags 段保留分欄u裡的網址。如果未提供,856段已檢查,許多段可以被指定,舉例:

    check-url-quick.pl –tags 310 410 856

  • –verbose|v 兩者輸出成功以及失敗的網址

  • –html 輸出格式為HTML。結果可以轉成檔案,可以透過 http 取得.從這個方式,有可能直接連結至書目記錄的編輯模式。使用此參數 –host-intranet 是必需的.

  • –host-intranet=http://koha-pro.tld 網路伺服器連結至Koha館員介面中書目記錄的編輯頁面。

  • –timeout=10 抓網址的時限。預設10秒。

  • –maxconn=1000 同時請求 HTTP 的數目. 預設是200個連結。

經由紀錄標示刪除紀錄

腳本路徑:misc/cronjobs/delete_records_via_leader.pl

做:刪除紀錄標示第 5 碼的內容為 『d』 的 MARC 紀錄

參數

  • -c|–confirm 若沒有此參數,程式將無法執行

  • -v|–verbose Verbose 模式

  • -t|–test 測試模式,不會刪除記錄。測試模式不能決定記錄/館藏被刪除,它只能讓您知道程式將刪除那些記錄或館藏。

  • -i|–delete-items 在刪除記錄前試著刪除。 記錄連同館藏無法刪除。

更新權威記錄

腳本路徑:misc/cronjobs/merge_authorities.pl

做:依照權威記錄的變動更新對應的書目資料

說明

此腳本的名稱是誤導。此腳本並未合併權威記錄反而合併與其連結的書目記錄。執行腳本時編輯權威記錄將適用於使用權威記錄的書目記錄。

Required by: AuthorityMergeLimit system preference

建議頻率:每晚

更新期刊

腳本路徑:misc/cronjobs/serialsUpdate.pl

做:檢查訂閱中的期刊是否有 「遲到」 的刊期,若有,此腳本設定它為遲到,並把下一期列為期待簽收。

建議頻率:每晚

自動更新館藏

腳本路徑:misc/cronjobs/automatic_item_modification_by_age.pl

Does: updates items based on the list of rules set forth in the Automatic item modifications by age tool

Required by: Automatic item modifications by age

建議頻率:每晚

Stock rotation

Script path: misc/cronjobs/stockrotation.pl

Does: moves items from one stock rotation stage to the next, if they are available for processing.

Each library will receive a report with 「items of interest」 for them for today’s rota checks. Each item there will be an item that should, according to Koha, be located on the shelves of that branch, and which should be picked up and checked in.

備註

The email sent is based on the SR_SLIP template. It can be customized in the Notices and slips tool.

The item will either:

  • have been placed in transit to their new stage library;

  • have been placed in transit to be returned to their current stage library;

  • have just been added to a rota and will already be at the correct library;

Upon check-in,

  • items that need to be transferred elsewhere will be put in transit and a message will pop up requesting the item be sent to their new branch.

  • items that are already at the correct library will be checked in and no message will pop up.

Required by: Stock rotation tool

建議頻率:每晚

參數

  • -a|–admin-email

    • An address to which email reports should also be sent

    • This is an additional email address to which all email reports will be sent, in addition to sending them to branch email addresses.

  • -b|–branchcode

    • Select branch to report on for 『email』 reports (default: all)

    • If the 『email』 report is selected, you can use the 『branchcode』 parameter to specify which branch’s report you would like to see.

    • The default is 『all』.

  • -x|–execute

    • Actually perform stockrotation housekeeping

    • By default, this script merely reports on the current status of the stock rotation subsystem. In order to actually place items in transit, the script must be run with the 『execute』 argument.

  • -r|–report

    • Select either 『full』 or 『email』

    • The 『report』 argument allows you to select the type of report that will be emitted.

    • The default is 『full』.

    • If the 『email』 report is selected, you can use the 『branchcode』 parameter to specify which branch’s report you would like to see.

  • -S|–Send-all

    • Send email reports even if the report body is empty

    • This argument causes even reports with an empty body to be sent.

  • -s|–send-email

    • Send reports by email

    • This argument causes the script to send reports by email.

  • -h|–help

    • Display the help message

OPAC

RSS Feeds

腳本路徑:misc/cronjobs/rss/rss.pl

做:給任何 SQL 詢問使用的 RSS XML 文件 (不是供搜尋結果 RSS feed 使用)。詳情

建議頻率:每小時

權威瀏覽器

腳本路徑:misc/cronjobs/build_browser_and_cloud.pl

做:在 OPAC 產生權威瀏覽的內容

Required by: OpacBrowser system preference

重要

此偏好與工作排程應祗適用於法語系統。

主題/著者雲

腳本路徑:misc/cronjobs/cloud-kw.pl

做:從 Koha Zebra 索引產生 HTML 鍵詞雲。misc/cronjobs/cloud-sample.conf 有若干此腳本運算元的範例。

頻率:這是您可每月執行一次的腳本類型,其內容並不常變動。

系統管理

服務量

腳本路徑:misc/cronjobs/services_throttle.pl

做:重設 xISBN 服務量

建議頻率:每晚

清理資料庫

腳本路徑:misc/cronjobs/cleanup_database.pl

做:截切 sessions 表單、清理 zebra 序列款目、作為記錄與待處理 MARC 檔案。

請參考 http://schema.koha-community.org/ Koha 資料庫綱要

參數 - –del-exp-selfreg

  • –del-unv-selfreg DAYS

    • 刪除 borrower_modifications 中所有早於 DAYS 的未驗證自助註冊。

  • –deleted-catalog DAYS

    • 從表單 deletedbiblio、deletedbiblio_metadata、deletedbiblioitems 和 deleteditems 中清除超過 DAYS 天前刪除的書目記錄。

  • –deleted-patrons DAYS

    • 從 deletedborrowers 表單中清除超過 DAYS 天前刪除的讀者。

  • –fees DAYS

    • 清除 accountlines 表單中早於 DAYS 天的項目,其中 amountoutstanding 為 0 或 NULL。

    • 在 –fees 的情況下,DAYS 必須大於或等於 1。

  • -h|–help

    • 取得協助訊息

  • –import DAYS

    • 從匯入表單中清除早於 DAYS 天的項目。

    • 這包括 import_batches、import_biblios、import_items、import_record_matches 和 import_records。

    • 在 import_batches 中,使用 –z3950 參數移除 Z39.50 搜尋結果的批次。

    • 如果未指定天數,則預設為 60 天。

  • --list-invites

    日數

    • 從早於 DAYS 天的 virtualshelfshares 表單中清除(未接受的)清單分享邀請

    • 如果未指定天數,則預設為 14 天。

  • –logs DAYS

    • 從 action_logs 表中清除早於 DAYS 天的項目。

    • 如果未指定天數,則預設為 180 天。

  • –log-modules

  • –preserve-logs

  • -m|–mail DAYS

    • 從 message_queue 表中清除早於 DAYS 天的項目。

    • 如果未指定天數,則預設為 30 天。

  • –merged

    • 從 Need_merge_authorities 表中清除已完成的項目。

  • –oauth-tokens

    • 刪除過期的 OAuth2 tokens

  • –old-issues DAYS

    • 從 old_issues 表清除超過 DAYS 天前的借出還入。

  • –old-reserves DAYS

    • 清除從 old_reserves 表中 DAYS 天以上的預約。

  • –restrictions DAYS

    • Purge patrons restrictions from the borrower_debarments table expired since more than DAYS days.

    • 如果未指定天數,則預設為 30 天。

  • –return-claims

  • –all-restrictions

    • 從 borower_debarments 表中清除所有過期的讀者限制。

  • –searchhistory DAYS

    • 從 search_history 表中清除早於 DAYS 天的項目。

    • 如果未指定天數,則預設為 30 天

  • –sessions

    • 清除工作階段表。

    • 如果您在使用者已登錄 Koha 時使用它,他們將須重新連線。

  • –sessdays DAYS

    • 僅清除大於 DAYS 天的工作階段。

  • –statistics DAYS

    • 從統計表單中清除超過 DAYS 天以上的項目。

  • –temp-uploads

    • Delete temporary uploads from the uploaded_files table older than the number of days specified in the UploadPurgeTemporaryFilesDays system preference.

  • –temp-uploads-days DAYS

  • –transfers DAYS

    • 從 branchtransfers 表單中清除已完成超過 DAYS 天的轉移。

  • –unique-holidays DAYS

    • 從 special_holidays 表單中刪除所有早於 DAYS 的單獨假日

  • –uploads-missing FLAG

    • 當 FLAG 為 true 時,刪除遺失檔案的上傳記錄,否則會計算

  • -v|–verbose

    • verbose 模式

  • –zebraqueue DAYS

    • 清除已完成超過 DAYS 天的 zebraqueue 項目。

    • 如果未指定天數,則預設為 30 天。

  • –z3950

    • 清除 Z39.50 儲存於匯入表單內的搜尋紀錄。

    • 要清除所有其他匯入資訊,請參閱上面的 – 匯入參數。

共享使用統計

路徑腳本:misc/cronjobs/share_usage_with_koha_community.pl

Does: sends your info to the Hea website if you’re sharing information via the UsageStats feature

頻率:每月

Search for data inconsistencies

Script path: misc/maintenance/search_for_data_inconsistencies.pl

Does: reveals problems in data, such as

Some of these issues can cause problems in circulation or catalog search, so it’s important that they be corrected.

There is no suggested frequency. This is a tool to be used when needed.

採訪

清除舊的建議

腳本路徑:misc/cronjobs/purge_suggestions.pl

做:從建議管理區域移除舊的建議。

參數

  • 幫助|?

    顯示協助資訊

  • 根據“管理於”日期定義要刪除的建議時期

    備註

    The system preference PurgeSuggestionsOlderThan can also be used to define the number of days used in the script. If using the system preference, don’t use the 『days』 parameter.

    備註

    基於 『管理於』 建議的天數。

  • 確認

    此參數對於腳本執行是必需的。

將建議以電郵送入程序

腳本路徑:misc/cronjobs/notice_unprocessed_suggestions.pl

做:將待處理的採訪建議告知基金擁有者

EDI 訊息處理

腳本路徑:misc/cronjobs/edi_cron.pl

做:送出與接收 EDI 訊息

頻率:每 15 分鐘

移除暫存 EDI 檔案

腳本路徑:misc/cronjobs/remove_temporary_edifiles.pl

做:移除 5 天前的暫存 EDI 檔案

E-resource management (ERM)

Harvesting cron job

Script path: /misc/cronjobs/erm_run_harvester.pl

Does: this script will run the SUSHI harvesting for any Active usage data providers set up in the E-resource management module.

Frequency: it is recommended you set it up to run at a regular interval (e.g., every month since providers usually produce statistics data monthly).

參數

  • --help or -h

    • Prints a help message

  • --begin-date

    • Set the start date for the harvest in yyyy-mm-dd format (e.g.: 『2023-08-21』)

  • --end-date

    • Set the end date for the harvest in yyyy-mm-dd format (e.g.: 『2023-08-21』)

  • --dry-run

    • Produces a run report, without actually doing anything permanent

  • --debug

    • Prints additional debugging information during the run

USAGE EXAMPLE

erm_run_harvester.pl --begin-date 2023-06-21 --debug

Will run the SUSHI harvest for Active usage data providers for the period starting 21 June 2023 to the present date (or to the date for which data is available). Additional debugging information about the way the harvest has run will be displayed.

報表

執行報表

Script path: misc/cronjobs/runreport.pl

Does: runs pre-existing saved reports, optionally sends the results by email.

參數

  • -h | --help

    • Displays help message

  • -m | --man

    • Displays full documentation

    • Same as --help --verbose

  • -v | --verbose

    • Verbose output

    • Without this parameter, only fatal errors are reported

  • --format=s

    • Selects output format

    • Possible values:

      • text

      • html

      • csv

      • tsv

    • At the moment, 『text』 and 『tsv』 both produce tab-separated output

    • Defaults to 『text』

  • -e | --email

    • Send the output by email (implied by --to or --from)

  • --send_empty

    • Send the email even if the report returns no results

    版本

    The --send_empty parameter was added in Koha version 23.11.

  • -a | --attachment

    • Attach the report as a file

    • Cannot be used with html format

  • --username

    • Username to pass to the SMTP server for authentication

  • --password

    • Password to pass to the SMTP server for authentication

  • --method

    • The type of authentication, i.e. LOGIN, DIGEST-MD5, etc.

  • --to=s

    • E-mail address to which to send report results

    • If --email is specified, but --to is not, the address in KohaAdminEmailAddress is used

  • --from=s

    • E-mail address from which to send report

    • If --email is specified, but --from is not, the address in KohaAdminEmailAddress is used

  • --subject=s

    • Subject for the e-mail

  • --param=s

    • Pass value for the runtime parameter

    • Repeatable

    • Provide one --param per runtime parameter requested for the report. Report parameters are not combined as they are on the staff side, so you may need to repeat parameters.

  • --separator=s

    • Separator character

    • Only for csv format

    • Defaults to comma

  • --quote=s

    • Quote character

    • Only for csv format

    • Defaults to double quote

    • Empty string is allowed

    版本

    The --quote parameter was added in Koha version 23.11.

  • --store-results

  • --csv-header

    • Add column names as first line of csv output

參數

  • reportID

    • Report ID Number from saved_sql.id

    • Multiple ID’s may be specified

    • Mandatory

USAGE EXAMPLES

runreport.pl 1

Will output results from report 1 in the terminal (STDOUT).

runreport.pl 1 5

Will output results from reports 1 and 5 in the terminal (STDOUT).

runreport.pl --format html --to admin@myDNSname.org 1

Will send results from report 1 to admin@myDNSname.org in HTML format.

runreport.pl --format html --to admin@myDNSname.org --param CPL --param FICTION 1

Will send results from report 1 to admin@myDNSname.org in HTML format. 『CPL』 will be passed to the first runtime parameter, and 『FICTION』 will be passed to the second runtime parameter.

runreport.pl --store-results 1

Will save the report results in the saved_reports database table, and they will be available from the staff interface in Reports > Guided reports > Saved report.

社會資料

取得社會資料報表

腳本路徑:misc/cronjobs/social_data/get_report_social_data.pl

做:從 Babelthèque 下載資料加入 OPAC 紀錄

建議頻率:每晚

更新社會資料

腳本路徑:misc/cronjobs/social_data/update_social_data.pl

做:以 Babelthèque 資料更新 OPAC 紀錄

守護行程

常駐程式會持續執行輔助 Koha 作業。 您的資料庫和網頁伺服器將作為常駐程式執行。大多數較新版本的 Koha 啟動兩個不同的常駐程式:

  • zebra - 此為索引伺服器

  • koha-indexer - 此守護行程使用新的和修改的數據(書目和權威)更新索引伺服器

這些守護行程由腳本 /etc/init.d/koha-common 啟動。

Zebra indexer daemon

腳本路徑:/usr/sbin/koha-indexer(從 /etc/init.d/koha-common 調用)

koha-indexer 腳本以守護行程模式調用 rebuild_zebra.pl。此模式下,腳本將連續運作並每30秒檢查數據庫中是否有新數據或修改過的數據。 然後將新記錄或修改後的記錄發送到Zebra 進行索引,這只需一秒鐘左右。與 cron job approach 相比,此方法的優點是搜尋系統對更改的反應快很多。

不適用的腳本

不應在未修改前執行這些:

腳本路徑:misc/cronjobs/update_items.pl

腳本路徑:misc/cronjobs/smsoverdues.pl

腳本路徑:misc/cronjobs/notifyMailsOp.pl

腳本路徑:misc/cronjobs/reservefix.pl

腳本路徑:misc/cronjobs/zebraqueue_start.pl