Loading...
 

Cron Job to Rebuild Search Index


You can rebuild index by visiting example.com/tiki-admin.php?page=search&rebuild=now

Since Tiki9, if you have a large site and do not use MySQL Full Text search, you should set up a Cron job to regularly rebuild the index.

How to do it varies from server to server, but here is an example. For a fuller description of the commands themselves, please see Unified Index - from the command line


Add this line for a daily rebuild in Tiki11 and up
0 0 * * * cd /var/www/html/tiki; php console.php index:rebuild >/dev/null 2>&1


To set RAM to 4 GB, increase max execution time, force an initial index cleanup and log
0 0 * * * cd /var/www/html/tiki; php -dmemory_limit=4G -dmax_execution_time=300 console.php index:rebuild --force --log >/dev/null 2>&1


 Tips


  • ‘’The last part “>/dev/null 2>&1” indicates to discard the output from the command (standard output and any errors messages produced).’’
  • ‘’The first 5 characters (separated by spaces) of the command set the time and frequency that the cron job will run. The characters refer to (in order): minute, hour, day, month, and weekday. So the above (0 0 * * * ) will run at midnight (0 minutes and 0 hour) every night.’‘

Works in Shell but not as a Cron Job

The environment for a cron job (e.g., the PATH variable) may not be the same as in shell (using SSL can cause this). That means that the above scripts may work in shell but not as a cron job. To solve this, set the cron job to run a shell script that sets the PATH variable before running the rebuild command.

To find out what the PATH variable should be, use the env command in shell on the server where the Tiki site is that you’re rebuilding the index for.

Let’s say the shell script is called cron.sh. The cron job would be as follows:
Cron job to run shell script
0 0 * * * sh cron.sh >/dev/null 2>&1


The shell script cron.sh would consist of the following:
cron.sh
#!/bin/bash

#this is the exact same setting as in the shell environment
PATH=/home/useraccount/perl5/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/useraccount/bin

#this is the actual command to rebuild the index
php -dmemory_limit=4G -dmax_execution_time=300 /home/useraccount/public_html/console.php index:rebuild


Related:

alias

doc.tiki.org


Bootstrap

AdminGuide

UserGuide

Keywords

Keywords serve as “hubs” for navigation within the Tiki documentation. They correspond to development keywords (bug reports and feature requests):

Accessibility (WAI and 508)
Accounting (7.x)
Articles and Submissions
Backlinks
Banners
Batch (6.x)
BigBlueButton audio/video/chat/screensharing (5.x)
Blog
Bookmark
Browser Compatibility
Link Cache
Calendar
Category
Chat
Clean URLs
Comments
Communication Center
Compression (gzip)
Contacts (Address Book)
Contact us
Content Templates
Contribution (2.x)
Cookie
Copyright
Credit (6.x)
Custom Home and Group Home Page
Date and Time
Debugger Console
Directory of hyperlinks
Documentation link from Tiki to doc.tiki.org (Help System)
Docs 8.x
Draw 7.x
Dynamic Content
Dynamic Variable
External Authentication
FAQ
Featured links
File Gallery
Forum
Friendship Network (Community)
Gmap Google maps
Groups
Hotword
HTML Page
i18n (Multilingual, l10n, Babelfish)
Image Gallery
Import-Export
Install
Integrator
Interoperability
Inter-User Messages
InterTiki
Kaltura video management (4.x)
Karma
Live Support
Login
Logs (system & action)
Look and Feel
Lost edit protection
Mail-in
Map with Mapserver
Menu
Meta Tags
Mobile Tiki and Voice Tiki
Mods
Module
MultiTiki
MyTiki
Newsletter
Notepad
Payment
Performance Speed / Load
Permissions
Platform independence (Linux-Apache, Windows/IIS, Mac, BSD)
Polls
Profiles
Profile Manager
Report
Toolbar
Quiz
Rating
Feeds
Score
Search engine optimization
Search
Search and Replace
Security
Semantic links (3.x)
Shadowbox
Shadow Layers
Share
Shopping cart
Shoutbox
Slideshow
Smiley
Social Networks
Spam protection (Anti-bot CATPCHA)
Spellcheck
Spreadsheet
Stats
Surveys
Tags (2.x)
Task
Tell a Friend, alert + Social Bookmarking
TikiTests (2.x)
Theme CSS & Smarty
Trackers
Transitions (5.x)
TRIM
User Administration including registration and banning
User Files
User Menu
Watch
WebHelp
WebDAV (5.x)
Webmail
Web Services
Wiki 3D
Wiki History, page rename, etc
Wiki Page Staging and Approval (2.x)
Wiki Plugin extends basic syntax
Wiki Syntax
Wiki structure (book and table of content)
Workspace
WSOD
WYSIWYCA
WYSIWYG (2.x)
XMLRPC


Tiki Newsletter

Delivered fresh to your email inbox!
Newsletter subscribe icon
Don't miss major announcements and other news!
Contribute to Tiki
Show php error messages