One of the most stunning features of Magento 2 is cron job that enables you to execute repetitive task periodically without any efforts. You can use this cron job to run various scheduled tasks, like.

  • Re-indexing
  • Catalog price rules
  • Sending newsletters
  • Generating Google Sitemaps
  • Customer notifications or alert messages
  • Auto update currency rates
  • Scheduled database logs cleanups
  • Cache cleanups
  • Generating site maps and more.

With just a date and time you are done with setting up cron. After that, the Magento cronjob manager will list all cron jobs and run it sequentially. When there is a number of cron jobs listed, you don’t know which job is currently in progress. Because of that, sometimes it happens when there is less time between executions of crons, it may create conflictions with one another. That’s the reason we always recommend you to check that particular cron is executed or not?
So, we are back with a super exciting blog that will help you to know which cron job is currently running on your Magento 2 Server using this small piece of code.
In the first step, we need to create a cron using “crontab.xml” file at the following location.
app\code\Vendor\Extension\etc\crontab.xml

Now, in second step, we need to create one more file named “Mycronfile.php” at this path.
app\code\Vendor\Extension\Cron\Mycronfile.php

In this third and last step we need to create cron collection file at this path. app\code\Vendor\Extesnion\Model\ResourceModel\Cron\Collection.php

That’s it for today, Let us know if you are facing an issue while implementing using this code by commenting below.

Happy Croning!

Click to rate this post!
[Total: 8 Average: 3.5]