Posted on

Magento 2 run a specific Cron without cron:run CLI command?

To make a long story short xdebug will not reliably stop on the breakpoints in my cron files when using the typical:

php bin/magento cron:run

Xdebug is all setup properly and sometimes it will work but 85% of the time it will not and just hang in CLI until I turn off listen for connections in phpstorm.

Is there a way to run just one cron file somehow? I had to actually copy and paste the contents of my cron file to a separate console command to test it properly in xdebug which is not ideal.

In Magento 1.x I used to use the AOE Scheduler for testing cron jobs with Xdebug by going to the admin, checkboxing the one I wanted, and choosing run from the dropdown and it worked fine.

I’m looking to use something like:

php bin/magento modulename:cronjob

which should always run the cron even if it is not scheduled.

Leave a Reply

Your email address will not be published. Required fields are marked *