1

I am trying to implementing cron job for my module but getting error in CLI.

I am using windows operating system.

here is crontab.xml

<?xml version="1.0" encoding="UTF-8"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Cron:etc/crontab.xsd">
<group id="customdesignsubcategories_cron">
    <job name="uploadFile_deletion" instance="vender\module\Cron\UploadFileDeletion" method="execute">
        <schedule>1/2 * * * *</schedule>
    </job>
</group>

here is UploadFileDeletion.php

<?php
namespace vender\module\Cron

class UploadFileDeletion
{
protected $_logger;
public function __construct(\Psr\Log\LoggerInterface $logger) 
{
    $this->_logger = $logger;
}
public function execute()
{
    $this->_logger->debug('Cron run successfully');
    return $this;
}
}

following commands i fire in CLI

php bin/magento cron:run --group="customdesignsubcategories_cron"

Error =>

[Magento\Framework\Exception\LocalizedException] Invalid Document
Element 'job': The attribute 'instance' is required but missing.
Line: 4

Element 'job': The attribute 'method' is required but missing.
Line: 4

Element 'schedule': Element content is not allowed, because the type definition is simple. Line: 5

Element 'schedule': [facet 'minLength'] The value has a length of '0'; this underruns the allowed minimum length of '5'. Line: 5

Element 'schedule': '' is not a valid value of the list type 'scheduleDeclaration'. Line: 5

Element 'run': This element is not expected. Expected is ( config_path ). Line: 8

cron:run [--group GROUP] [--bootstrap BOOTSTRAP]

0

try changing your crontab.xml to this:

<?xml version="1.0" encoding="UTF-8"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Cron:etc/crontab.xsd">
<group id="customdesignsubcategories_cron">
    <job name="uploadFile_deletion" instance="vender\module\Cron\UploadFileDeletion" method="execute">
        <schedule>*/2 * * * *</schedule>
    </job>
</group>

Also, ensure your file is indented with spaces instead of tabs (if not done already)

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.