1

I have followed the tutorial on Magento dev docs to create a custom crontab. Checking the cron_schedule table and various logs, I can see that cron is successfully running M2 jobs (e.g. indexer, mailers), but not the custom crontab. There is no mention of it at all - no errors in the Magento or server logs; no entry in cron_schedule.

I have manually run cron serveral times, seeing the message "Ran jobs by schedule" each time. I have set cron to log to var/log/magento.cron.log, and there I see only the same "Ran jobs by schedule" message - no other output from the other M2 cron jobs which I know are running (because they show status "success" in cron_schedule).

The custom module crontab (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="cronjob_default" instance="Vex\SportIntBase\import\StoredProcCronDefault" method="execute">
            <schedule>* * * * *</schedule>
        </job>
    </group>
</config>

The class:

namespace Vex\SportIntBase\import;
use \Psr\Log\LoggerInterface;

class StoredProcCronDefault
{
    protected $_logger;
    private $_fetchers;

    const PATH = __DIR__ . 'vendor/vex/module-sport-int-base/import';

    public function __construct(LoggerInterface $logger) {
        $this->_logger = $logger;
        $this->_fetchers = array(
            'price_fetch.php',
            'products_fetch.php',
            'stock_fetch.php'
        );
    }

    public function execute() {
        $this->_logger->info('Beginning VexSport Stored Procedure Run (default)');
        foreach($this->_fetchers as $runSP) {
            include(SELF::$PATH) . $runSP;
        }
    }
}

Version info: M2 2.1.2, PHP 7.0.13, Debian 8.6.

Thanks for any ideas or suggestions. I'm stumped.

1

I think this is Usefull for you,

You need to use n98-magerun2 this will show all the error in cron jobs,

Download and Install Phar File

<m2-dir>$ wget https://files.magerun.net/n98-magerun2.phar

After seen in have n98-magerun2.phar file. with in m2-directory

next you need to list all the cron jobs, follow this command:

<m2 -dir> $ ./n98-magerun2.phar sys:cron:list

then, run cron job:

<m2- dir> $ ./n98-magerun2.phar sys:cron:run [cron jobname]

This will show you where error occur in your code.

follow this link

  • n98-magerun.phar is just for M1, while the author is asking for M2 solution – PY Yick Jun 30 '17 at 5:25
  • @PYYick i updated my answer, check it n98-magerun2.phar is there in magento 2 – Rajkumar .E Jun 30 '17 at 5:31

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.