How to create cron job

Cron feature is the most useful utility that you can find in any Unix-like operating system, but also on windows operating system. This utulity is used to schedule commands at a specific time. These scheduled commands are called "Cron Jobs" or so-called "Cron tasks". In this article I will point you the way of how to set up the cron task in context of PrestaShop's modules and features that are based on Cron Job. I will describe 3 methods:

  1. PrestaShop's task manager module
  2. Hosting account cron job feature
  3. External service like easycron

Set up a cron job for PrestaShop purposes

So, let's say that one from your modules has a support of Cron Job feature. Usually such module points that you need to use special url in Cron Job scheduler. Copy this URL carefully, and use in one method described below. Each time that Cron Job scheduler will run such url - module will run some actions.

 

  1. PrestaShop's cron service
    it's a default prestashop's feature that allows to run tasks with defined frequency. As i previously mentioned - it does not work well, the service is frequently under maintenance mode and tasks are not always executed. Maybe something changed now, so it is worth to give it a chance :). You can find cron task manager module in PrestaShop's back office:
    Cron task manager in PrestaShop

    Just add there new task, and paste the url from module to "target link" field:
    cron task create new job

  2. hosting provider service: cron job
    I suggest to use this method because it will always work and it will be not affected, like the prestashop's cron job feature.
    Each hosting provider offers cron job feature in hosting control panel. You can set up there own cron task that will be executed with defined frequency.
    You host your website on ovh and you linked the cron job documentation page. There is an image:

    cron job in ovh

    Inside the field i pointed with red arrow type the path to the file:
    it will be something like: www/shop/modules/modulename/cronjob.php?key=6ff93b4666449af2649f92ab09305376

    first part of path: www/shop may be different, i do not know exact structure of files on your hosting account. You can use file explorer (which is a part of hosting control panel too) to fully identify it.


  3. external third party services
    Over the internet you can find a lot of free "cron jobs" services to run tasks with defined frequency. For example: https://www.easycron.com/
    1. Create there new cron job task: 
      easymanager cron job manager
    2. Copy-paste the task url to configuration page and set the frequency of its execution:
      easymanager cron job manager
    3. fill out the "cron job name", its 'description' etc. 
      easymanager cron job manager
    4. save the cron job

  1. How to create cron job
    Cron feature is the most useful utility that you can find in any Unix-like operating system, but also on windows operating system. This utulity is used to schedule commands at a specific time. These scheduled commands are called "Cron Jobs" (...) more ›
  2. Disabled overrides
    Some part of MyPresta.eu modules uses overrides mechanism. In context of PrestaShop overriding is a way to "override" Prestashop's core files (class files and controller files). In simple words core files defines how PrestaShop works. So, w (...) more ›