What's a cron task and why do I need one?

On all our commercial versions, HikaShop can execute automatic processes. Some features like "currencies rates auto update", "waitlist notification", "out of stock notification", "order auto cancel", "google products", "subscriptions" need it but we are planning on add features like start sale customers notifications which will also require a cron task.

For those actions to be executed, HikaShop needs to be triggered regularly, and each time HikaShop is triggered, it will check if some tasks have to be executed and then do what needs to be done.

A cron task is a system which will automatically trigger HikaShop without any human intervention.

 

Create your cron task on our server

As some hosting companies don't enable you to create a cron task on your own server and also because some of our users have no clue what is a cron task, we created a cron service and an easy way to add a cron task directly via your HikaShop configuration!

So, within two clicks, you will be able to create your cron task through the page :

Cron Config

 

  • Go on your HikaShop configuration page ("Hikashop->System->Configuration")
  • Click on the tab Cron

Create cron

  • On this interface, you can specify the Minimum delay between two cron tasks, which is just for security (so that your website won't be triggered too often) but this parameter has no impact on the real cron frequency (they both should have the same value).
  • Click on the button Create/Edit your Cron task.
  • A popup will open and you will directly see your cron url added (you don't have change it!).
  • Make sure the Cron URL is the right one (you should not have to modify this url!)
  • Activate your Cron Task (if you select "Activated : No", our server won't trigger your website any more)
  • Select your frequency to meet your needs
    You can select either Every 15 minutes, Every 30 minutes or Every 1 hour.
    This frequency should be the same as (or bigger than) the parameter "Minimum delay between two cron tasks"
  • Click on the save button.
  • That's all you have to do and now our server will trigger your HikaShop component at the specified frequency.
  • You have to do this procedure only one time, then you can forget about it!
  • On this same popup, you can also see an area Last Report.
    This area enables you to check if your website has been triggered properly by our server and when.
    You can see our local time, the next time your website will be triggered and the last report.
  • You can now close this popup

 

Create your cron task on your own server

If you have the possibility and the knowledge to create a cron task on your own server, then you should do it and stop the cron task on our server to be completely independent from our server. You can contact your hosting company for directions on how to set it up on your hosting plan.

You should trigger your HikaShop cron url at a fixed frequency depending on your needs (every 15 minutes is usually a good frequency)

You can see your cron url on your HikaShop configuration page ("Hikashop->System->Configuration"), tab cron.

cron url

 

Linux System

You can use one of the following command depending on your server:

  • lynx -source "http://www.yourwebsite.com/index.php?option=com_hikashop&ctrl=cron" > /dev/null
  • wget -O /dev/null "http://www.yourwebsite.com/index.php?option=com_hikashop&ctrl=cron" > /dev/null

 

Check that your cron task is working

  • We implemented an easy way for you to check that your cron task is working.
  • Go on your HikaShop configuration page ("Hikashop->System->Configuration") and click on the tab Cron

Test your cron

  • On the Report area, you can see an option to have HikaShop sending you a report each time it is triggered.
    So you can turn ON this option and once your done with your tests, you can then turn it Off.
  • Also, on the Last Cron area, you can see the last time your cron has been triggered, who triggered it and the latest report.

 

If your cron task is not working, you should:

  • Make sure your website can be triggered via your browser:
    Click on your cron url. That will trigger it manually via your browser so you will see if this url can be reached or not.
  • If you use a third-party SEF component, your website may redirect the current page to the SEF one which will break our own cron service.
    So you can either configure your SEF component to not transform non-SEF into SEF urls or directly write your sef cron url on our cron interface. That can happen with sh404sef.
  • Make sure your website can be triggered by the outside:
    If you have an .htaccess with password protection, your website will obviously not accept to be triggered by an anonymous user.
  • If you use a security component on your Joomla website, this component might block our cron task. RSFirewall: You should disable the DoS protection from the Components > RSFirewall > Configuration > Active scanner configuration options.
  • If you use Cloudfare please configure it to allow the cron task to go through.
  • If you configured your cron task on your own server, check the report of your own cron task and you may also want to apply this workaround:
    Create a php file at the root of your joomla website with the code below in it where you will replace yourwebsite.com by your website.
    <?php
    header("Location: http://www.yourwebsite.com/index.php?option=com_hikashop&ctrl=cron");
    exit();
    
    Then, instead of calling the hikashop cron page, you will call your php file you just created. Like that, for example:
    wget -O /dev/null "http://www.yourwebsite.com/myfile.php" > /dev/null
  • If you use our own server to trigger your website, please make sure you enabled our server IP to trigger your website every X minutes! (you might block it if you have some security checks on the number of connections per IP)