How can I execute my cron class in command line especially for testing.

normally one could php -f myfile.php


Calling a method's class: php -r 'include "/path/to/file.php"; ClassName::MethodName();'

I have a Cron class and would like to test in command line to display E.G: 'Hello World!?


Run cron from the command line Command options:

$  bin/magento cron:run [--group="<cron group name>"]

Like $ php bin/magento cron:run --group="customgroupname_cron"

where --group specifies the cron group to run (omit this option to run cron for all groups)

To run the indexing cron job, enter:

bin/magento cron:run --group index

To run the default cron job, enter:

bin/magento cron:run --group default
| improve this answer | |

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.