app/code/BatChat/Module/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="batchat_module_cron_cronclass" instance="BatChat\Module\Cron\CronClass" method="execute">
<schedule>* */3 * * *</schedule>
</job>
</group>
</config>
app/code/BatChat/Module/Cron/CronClass.php
<?php
namespace BatChat\Module\Cron;
class CronClass {
/**
* @var \Psr\Log\LoggerInterface
*/
protected $logger;
/**
* CronClass constructor.
*
* @param \Psr\Log\LoggerInterface $logger
*/
public function __construct(
\Psr\Log\LoggerInterface $logger
) {
$this->logger = $logger;
}
/**
* Description
*
* @return void
*/
public function execute()
{
$this->logger->info("Cron job running");
}
}
bin/magento cron:run [--group="<cron group name>"]
https://devdocs.magento.com/guides/v2.0/config-guide/cli/config-cli-subcommands-cron.html
https://devdocs.magento.com/guides/v2.2/config-guide/cli/config-cli-subcommands-cron.html
SELECT * from cron_schedule WHERE job_code like '%job_name%';