1. Home
  2. Technical
  3. Setting up cron jobs in Magento 2

Setting up cron jobs in Magento 2

In order to run Magento 2 you need to add 3 cron jobs to the webhosting management.

The interval of running the jobs should be 1 minute, so please choose System from the  Execution type dropdown menu, and in the  Schedule manually field you need to enter * * * * * (five asterisks, spaces between them).

The following examples work assuming Magento is installed in the default ~/domains/www.example.com/htdocs directory. The double square brackets contain Zone system variables that set the default PHP version and the home directory of the user’s domain. The PHP version is the PHP version selected for the virtual server (even if Magento is hosted on a subdomain). If Magento is not located in the htdocs folder, you need to change this part (note that each line of htdocs is written 2 times, in the command and in the log).

Default cron Magento:
[[$PHP]] [[$D2ND_A]]/htdocs/bin/magento cron:run | grep -v "Ran jobs by schedule" >> [[$D2ND_A]]/htdocs/var/log/magento.cron.log
Update cron (for versions below 2.4):
[[$PHP]] [[$D2ND_A]]/htdocs/update/cron.php >> [[$D2ND_A]]/htdocs/var/log/update.cron.log
Setup cron (for versions below 2.4):
[[$PHP]] [[$D2ND_A]]/htdocs/bin/magento setup:cron:run >> [[$D2ND_A]]/htdocs/var/log/setup.cron.log
When setting up alerts/reports, it’s important to consider that the first job will usually terminate with an error (because no line was found other than the normal job message) – so Report on errors will send an email on every run, and you should select Report on output.

 

Updated on 19. Aug 2024
Was this article helpful?

Related Articles