I have created a module which has a Tests.php file.

I wanted to run this execute() method from Tests.php class to be executed once every Day.

I have created a Corn job, But it is Not Executing as expected, please check my code and point me where I am missing.

Please let me know how I can call the Method from a


<?php /**
* Copyright © 2016 Magento. All rights reserved. * See COPYING.txt for license details.
\Magento\Framework\Component\ComponentRegistrar::register( \Magento\Framework\Component\ComponentRegistrar::MODULE, 'Autosynch_synchProduct',


<?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="custom_cronjob" instance="Autosynch\synchProduct\Cron\Tests" method="execute">
            <schedule>* * * * *</schedule>


namespace Autosynch\synchProduct\Cron;
use \Psr\Log\LoggerInterface;

class Tests {
    protected $logger;

    public function __construct(LoggerInterface $logger) {
        $this->logger = $logger;

   * Write to system.log
   * @return void

    public function execute() {
        $this->logger->info('Cron Works');


Here is the database snapshot.

enter image description here

  • Please check cron schedule is created in database or not. – Dhaduk Mitesh Jun 19 '18 at 10:24
  • Added the screenshot of the Database table of Cron Schedule – JB Pakalapati Jun 19 '18 at 10:38
  • Means not running. Right? – Dhaduk Mitesh Jun 19 '18 at 10:38
  • Yes, Do i need to wait for some time. Any default time is applied before executing ..? – JB Pakalapati Jun 19 '18 at 10:40
  • 1
    Just to confirm, is your crontab file actually called crontab.xml and not corntab.xml as per your question? – sduif Jun 19 '18 at 15:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.