<?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Cron:etc/crontab.xsd"> <group id="default"> <job name="cron_name" instance="Magenticians\Mymodule\Cron\Run" method="execute"> <schedule>*/1 * * * *</schedule>--> </job> </group> </config>In the code above, I have scheduled it for one minute. I have set the group id default and job name as cron_name, and you can change them if you want.
<?php namespace Magenticians\Mymodule\Cron; class Run { protected $_logger; public function __construct( \Psr\Log\LoggerInterface $logger ) { $this->_logger = $logger; } public function execute() { //Edit it according to your requirement $this->_logger->debug('Cron run successfully'); return $this; } }
php bin/magento cache:flush php bin/magento cron:runYou can also run Cron job for one group only by running this command: php bin/magento cron:run –group=”your_group_name” To check whether the Cron is working properly, go to var/log/debug.log of your store and you will see the text Cron run successfully in it. Go to cron_schedule table of database and you will see a new entry in it with your Cron job name.
Your greatest possible competitive advantage can be your clients and the interactions they have with… Read More
Digital marketing KPIs are measurable values that marketing teams use to track progress toward desired… Read More
In today's digital age, fraud poses a significant threat to businesses of all sizes. As… Read More
Financial crimes continue to evolve and proliferate in our increasingly digital, global economy. From complex… Read More
In the highly competitive modern workplace, trust, and employee loyalty are crucial factors for long-term… Read More
In the ever-evolving world of small business developing and implementing effective marketing strategies is critical to… Read More
View Comments
Thanks for sharing!
You're Welcome!
hello sir i do the same process but i don't know how to connect with ssh ???
You just have to enter your server credentials in your SSH terminal to connect it with your store. You can also Putty for it.
my server is localhost...and even i don't know the credentials and also SSH terminal??? Can you explain it more...I use Putty but it showing the Connection refused error????
when i run the cron:run cmd it show's me Ran job by schedule???
what should i do???
Dear Syed,
I have created a custom module and the above cron code is added accroding to you guide but I get the following error when I try to run the the run command
[MagentoFrameworkExceptionLocalizedException]
Invalid Document
Element 'job': Character content other than whitespace is not allowed because the content type
is 'element-only'.
Line: 4
Check the code in crontab.xml (line 5), remove the "-->" after "
Hi Syed ..I have created one cron ..in custom module.. inside cron php file. i have written code to get and save data from customer and product tables..while running the cron it is showing "ran by cron schedule". but it is not executed and result message not stored in the logger file