1

I am trying to customize Ebizmart Mailchimp extension. This extension has few batch processing which are run by Cron job. My Server is in Ubuntu VM and my IDE is netbean run on Windows. Debugging elsewhere is fine.

By customizing Ebizmart Mailchimp extension, I’ll collect specific subscribers and send them to mailchimp account. If I could trace its underlying php files which are run by cron job, I could easily modify its model.

Thanks.

  • For things like this I generally isolate functionality and trigger via my own console commands. Debug in console script. Once confirmed working as expected or whatever then i work back into a cron process. Context in console and cron are the same. – Dominic Xigen Jun 26 at 23:09
3

You could use Magerun. Magerun contains a command through which you can manually trigger a cronjob.

use the following command and then select a number for the specific job:

Magento 1

n98-magerun.phar sys:cron:run

https://github.com/netz98/n98-magerun#run-cronjob

Magento 2

n98-magerun2.phar sys:cron:run

https://github.com/netz98/n98-magerun2

  • Yes, I can run specific Cron Job in this way. That was not my issue. When I run that Cron Job, I want to run debugger and debug that method as well. How is it possible? – Agilox Aug 27 '18 at 7:01
1

Here is what I am using:

list cron jobs-> magerun sys:cron:list

run specific cron job -> sys:cron:run [cron_job_name]

I would like to know more about tools to help debugging.

0

Create a new file, for example, test.php and put it in your magento2 pub directory with the following code:

<?php
require __DIR__ . '/../app/bootstrap.php';

class TestMyClass
    extends \Magento\Framework\App\Http
    implements \Magento\Framework\AppInterface
{
    public function launch()
    {
        $this->_state->setAreaCode(\Magento\Framework\App\Area::AREA_ADMINHTML);
        $myClass = $this->_objectManager->create('NameSpace\YourClassName');
        $myClass->execute(); // In cron jobs we usually use the execute() method as the entry point
        return $this->_response;
    }
}

$bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $_SERVER);
/** @var \Magento\Framework\App\Http $app */
$app = $bootstrap->createApplication('TestMyClass');
$bootstrap->run($app);

And then run yourdomain.local/test.php

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.