Hello Magento Friends,

Today I am going to explain Magento 2: How To Setup Cron Time By Configuration

You can schedule cron dynamically with setup cron time by configuration. Sometimes developers set static time expressions to set cron in a custom module. So whenever the admin needs to make changes to the time expression, there is a need to change the crontab.xml file. Using the below steps the admin can quickly make changes to the time expression from the admin configuration and there is no need to make modifications in the crontab.xml file.

Let’s get started,

Steps to Setup Cron Time by Configuration in Magento 2:

Step 1:  First you need to add crontab.xml in the following path

app\code\Vendor\Extension\etc\crontab.xml

Step 2:  Need to add a new group on system.xml in the following the path

app\code\Vendor\Extension\etc\adminhtml\system.xml

Step 3: Now add Cronconfig.php in the following path

app\code\Vendor\Extension\Model\Config\Cronconfig.php

Step 4: Now add Cronfile.php in the following path

app\code\Vendor\Extension\Cron\Cronfile.php

Conclusion: 

Hence, now all are able to Setup Cron Time by Configuration in Magento 2. In case of any difficulty let me know in the comment section below. Stay Safe, Stay Home, and Stay Updated!

Happy Coding

[Total: 3   Average: 5/5]