[Koha-devel] cron, env, etc

Paul paul.a at aandc.org
Fri Sep 7 19:39:46 CEST 2012


At 11:13 AM 9/6/2012 -0300, Tomas Cohen Arazi wrote:

Tomas - I'm taking the liberty of Cc:ing the devel list (you suggested that 
you had spoken with some of them) but would thank you for the 'off-list' 
exchange of emails.

I have spent quite a bit of time checking various 
possibilities/combinations to ensure that a user cron, re-indexing zebra, 
functions as expected on various combinations of Koha 3.6.x and 3.8.4 on 
Ubuntu 10.04 and 12.04 (the two current Ubuntu LTS servers) on both 32- and 
64-bit boxes.

I have come to the conclusion that the use of crontab as outlined in RESULT 
[B] "rewritten" (see below) is fully functional, is a single "edit" at the 
time of installation, and could be included with total clarity in 
INSTALL.ubuntu and on the Wiki. The use of cron.d/koha RESULT [C] "second 
scenario" is also functional, but requires two edits at install time (and 
I've included a couple of minor caveats.)

I have not looked at the "package", only at various tarballs, so do not 
know under what conditions either crontab or cron.d may be used.  ISTR 
reading that package and tarball directory structure differs, so am not at 
all certain how close the two "installs" should or could be maintained.

HTH - regards - Paul

NOTES:

[A] From $ man cron :
"cron also reads /etc/crontab, which is in a slightly  different  format 
(see  crontab(5)). Additionally, cron reads the files in /etc/cron.d: it 
treats  the  files  in  /etc/cron.d as  in  the  same  way  as  the 
/etc/crontab  file  (they  follow the special format of that file, i.e. 
they  include  the  user  field).  However,  they  are  independent  of 
/etc/crontab:  they  do  not, for example, inherit environment variable 
settings from it."

[B] From 3.8.4 INSTALL.ubuntu :
5.2.2 Zebra Indexer
Add an entry in Koha user crontab to scheduled added/updated/deleted records
indexing by Zebra with this command:
   <path/to/koha>/misc/migration_tools/rebuild_zebra -z -b -a

[C] From <http://wiki.koha-community.org/wiki/Koha_on_Ubuntu> [abbreviated]

3 - Setup the environment variables used by Koha scripts
$ sudo gedit /etc/cron.d/koha
Add
KOHA_CONF=/etc/koha/koha-conf.xml
KOHAPATH=/usr/share/koha
PERL5LIB=$KOHAPATH/lib
(Alternatively ... same result.)
$ sudo gedit /etc/bash.bashrc.local
Add
export KOHA_CONF=/etc/koha/koha-conf.xml
export PERL5LIB=/usr/share/koha/lib

5b - Reindexing Choices
Option #1: See 
http://wiki.koha-community.org/wiki/Background_indexing_with_Zebra
Option #2: Add a cronjob to index your zebra database.
$ sudo gedit /etc/cron.d/koha
Add
# The cronjobs
*/5 * * * *    koha    $KOHAPATH/bin/migration_tools/rebuild_zebra.pl -a -b 
-z &> /dev/null

RESULTS:

[B] above does not funtion. It does function if rewritten as:

5.2.2 Zebra Indexer
Add a Koha user cron job to schedule added/updated/deleted record indexing 
by Zebra with this command:
$ sudo vi /etc/crontab
Append the following lines:
KOHA_CONF=/etc/koha/koha-conf.xml
KOHAPATH=/usr/share/koha
PERL5LIB=$KOHAPATH/lib
*/1 * * * *    koha    $KOHAPATH/bin/migration_tools/rebuild_zebra.pl -a -b 
-z &> /dev/null
:x

[C] {5b Option 1 - respectfully for Frédéric - not explored "This solution 
is completly outside Koha"}

First scenario: para 3 "cron.d" plus para 5.b Option 2 does not function 
(probably due to [A])

Second Scenario: para 3 "Alernatively" plus para 5.b Option 2 does 
function, with two possible caveats:
(a) Comparing my notes from various "new installs" versus "sandbox testing 
edits", I suggest adding 'export KOHAPATH=/usr/share/koha' to .bashrc 
between the other two en vars
(b) For a [user] cron, I prefer to 'export' from /home/[user]/.bashrc 
rather than /etc/bash.bashrc.local

---
Maritime heritage and history, preservation and conservation,
research and education through the written word and the arts.
<http://NavalMarineArchive.com> and <http://UltraMarine.ca>



More information about the Koha-devel mailing list