I created a custom cron job in my custom module. But, when I check the cron schedule, it's all in pending and don't work at all like in the picture below. Does that mean there's error on my cron job?
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="custom_crongroup">
<job name="custom_cronjob" instance="Test\Show\Cron\Test" method="execute">
<schedule>* * * * *</schedule>
</job>
</group>
</config>
Cron/Test.php :
<?php
namespace Test\Show\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('Cron Works');
}
}
Best Answer
Check the cron log for any errors. Make sure var/log folder have 777 permissions. If you still didn't find any solution, paste your crontab.xml file and the file your running.