Get Free Audit

How to Set Up CronJobs in Magento 1.x and Magento 2.0. Comparison

Feb 11, 2016

2093 Oleg Semenov

How to Set Up CronJobs in Magento 1.x and Magento 2.0. Comparison

Before I tell you about the cron jobs in Magento 2.0, let me remind you how it can be enabled in Magento 1.x.

Magento 1.x

First of all, you need to create a module (I hope that if you are reading this article, you remember how it can be done :) ). After that you need to add the module to the config.xml file.


Next step is to create a file model:

app/code/Belvg/Mymodule/Model/Cron.php.


This task is triggered every minute and writes messages in the log.

Now I will tell you how to enable cron jobs in Magento 2.0.

How can you do it?
This is also relatively easy and can be done in 2 steps:

1. Create a file app/code/Belvg/Mymodule/etc/crontab.xml

app/code/Belvg/Mymodule/etc/ with the following content:

Andrey_Dubina
Partner With Us Let's discuss how to grow your business. Get a Free Quote.
Talk to Andrey


2. Create a class app/code/Belvg/Mymodule/Model/Cron.php


That’s it.

We created a cronjob in Magento 2. Now in logs: var/log/system.log, you can see the following message:

[2016-01-14 08:00:00] main.INFO: Hello from Belvg

Hope it will help to adapt your extensions for Magento 2.0.

Andrey Dubina
Partner With Us Looking for a partner to grow your business? We are the right company to bring your webstore to success. Talk to Andrey

Post a new comment

BelVG Newsletter
Subscribe to our mailing list and get interesting stuff and updates to your email inbox.
Email *