I am trying to create a cron job for my custom module but when I run bin/magento cron: run. It shows "Ran jobs by schedule" in the command line but nothing happens in cron_scheduler table.
My crontab.xml looks
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Cron:etc/crontab.xsd"> <group id="custom_crongroup"> <job instance="AO\MultiStore\Cron\Reminder" method="execute" name="ao_multistore_cron"> <schedule>* * * * *</schedule> </job> </group> </config>
My cron_groups.xml looks
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Cron:etc/crontab.xsd"> <group id="custom_crongroup"> <job instance="AO\MultiStore\Cron\Reminder" method="execute" name="ao_multistore_cron"> <schedule>* * * * *</schedule> </job> </group> </config>
I know I have created a new group id but have already tried luck with the index and default. When I hit "crontab -l" it shows me all 3 paths necessary
*/22 * * * * /opt/cpanel/ea-php73/root/usr/bin/php /home1/bgjsjlmy/public_html/speedsports/update/cron.php >> /home1/bgjsjlmy/public_html/speedsports/var/log/update.cron.log */24 * * * * /opt/cpanel/ea-php73/root/usr/bin/php /home1/bgjsjlmy/public_html/speedsports/bin/magento setup:cron:run >> /home1/bgjsjlmy/public_html/speedsports/var/log/setup.cron.log */23 * * * * /opt/cpanel/ea-php73/root/usr/bin/php /home1/bgjsjlmy/public_html/speedsports/bin/magento cron:run 2>&1 | grep -v "Ran jobs by schedule" >> /home1/bgjsjlmy/public_html/speedsports/var/log/magento.cron.log
Don't worry about the 23 and 24 I have also used with ***** but no luck. I don't know what am I doing wrong with this. Can someone please help?
Hi @rizvialamd0b13 ,
Please update your cron_groups.xml with below content.
<?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Cron:etc/cron_groups.xsd"> <group id="custom_crongroup"> <schedule_generate_every>1</schedule_generate_every> <schedule_ahead_for>4</schedule_ahead_for> <schedule_lifetime>2</schedule_lifetime> <history_cleanup_every>10</history_cleanup_every> <history_success_lifetime>60</history_success_lifetime> <history_failure_lifetime>600</history_failure_lifetime> <use_separate_process>1</use_separate_process> </group> </config>
Execute below commands
bin/magento setup:upgrade
bin/magento setup:di:compile
bin/magento s:s:d -f
bin/magento cache:clean
bin/magento cron:run
Problem Solved? Accept as Solution!
Hope it helps!
Thanks