Run Klevu CRON independent of Magento 2 CRON

In case of larger product catalogs, from lots of processes relying on Magento cron, sometimes klevu cron keeps on running all the time or will be in a queue because of other module crons.

To avoid this, as an alternative, one can setup an external shell script that runs independently of Magento cron.

Follow the steps below to setup external script in Magento 2:

  1. Login into Magento Admin Panel.
  2. Please setup the below command to execute as an independent CRON Job every 30 minutes.
    php bin/magento klevu:syncdata --updatesonly

    Note:Please note, when the product sync is running, Klevu Magento 2 plugin creates a temporary lock file inside <magento-root-folder>/ pub folder to avoid executing multiple copies of Klevu’s product sync at the same time. Please make sure that the folder has enough permission to create the file.

  3. Go to app → code → Klevu → Search → etc and open crontab.xml OR vendor → klevu → module-productsearch → etc and open crontab.xml.
  4. Remove or comment out the following entry from the crontab.xml file.
    <job name="klevu_search_product_sync" 
    instance="Klevu\Search\Model\Product\Sync" method="run">
              <schedule>0 */3 * * *</schedule>    
    </job>
    
  5. As you are setting up an external CRON, please comment out all the code of schedule function inside Klevu\Search\Model\Sync.php
    public function schedule($time = "now"){
      //all code inside function should be commented out...
    }
    
  6. Go to app → code → Klevu → Content → etc and open crontab.xml OR vendor → klevu → module-content → etc and open crontab.xml
  7. Remove or comment out the following entry from the crontab.xml file.
    <job name="klevu_search_content_sync" 
    instance="Klevu\Content\Model\Content" method="run">
              <schedule>0 */3 * * *</schedule>    
    </job>