I Have created the custom cron in my custom module. 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="samplecron" instance="Learning\GreetingMessage\Cron\Run" method="execute">
<schedule>*/1 * * * *</schedule>
</job>
</group>
</config>
Then run.php
<?php
namespace Learning\GreetingMessage\Cron;
class Run
{
protected $_logger;
protected $_oredrcontroller;
public function __construct(
\Psr\Log\LoggerInterface $logger,
\Learning\GreetingMessage\Controller\Index\Test $ordercontroller
)
{
$this->_logger = $logger;
$this->_oredrcontroller = $ordercontroller;
}
public function execute()
{
$this->_oredrcontroller->execute();
$this->_logger->debug('Cron run successfully');
return $this;
}
}
I execute following commands in terminal
php bin/magento setup:upgrade
php bin/magento cache:flush
sudo chmod -R 777 .
php bin/magento cron:run
But my cron not working. In the function contorller \Learning\GreetingMessage\Controller\Index\Test
execute . I wrote code to update values in my table. Nothing happens