hello,
on magento 2.2.1, I followed this:
http://devdocs.magento.com/guides/v2.2/config-guide/cron/custom-cron-tut.html
and it works. Then I wanted to apply it to my custom (working) module:
/app/code/hoop/Util/Block/Cron/Test.php
<?php namespace Hoop\Util\Cron; use \Psr\Log\LoggerInterface; class Test { protected $logger; public function __construct(LoggerInterface $logger) { $this->logger = $logger; } /** * Write to system.log * * @return void */ public function execute() { $this->logger->info('checkme'); } }
etc/crontab.xml:
<?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="hoop_cronjob" instance="Hoop\Util\Cron\Test" method="execute"> <schedule>* * * * *</schedule> </job> </group> </config>
but it's not working, what am I doing wrong?
Thanks a lot
Solved! Go to Solution.
Your path define Block and in your xml file you doesn't define Block file in path,
/app/code/hoop/Util/Block/Cron/Test.php and your Test.php file inside only Cron Folder.
Verify first your path and file would be both same as decalre in xml file.
Your path define Block and in your xml file you doesn't define Block file in path,
/app/code/hoop/Util/Block/Cron/Test.php and your Test.php file inside only Cron Folder.
Verify first your path and file would be both same as decalre in xml file.