cancel
Showing results for 
Search instead for 
Did you mean: 

custom module cronjob

SOLVED

custom module cronjob

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

1 ACCEPTED SOLUTION

Accepted Solutions

Re: custom module cronjob

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.

If Issue Solved, Click Kudos/Accept As solutions. Get Magento insight from
Magento 2 Blogs/Tutorial

View solution in original post

1 REPLY 1

Re: custom module cronjob

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.

If Issue Solved, Click Kudos/Accept As solutions. Get Magento insight from
Magento 2 Blogs/Tutorial