1

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

Normally one could php -f myfile.php

OR

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

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

1 Answer 1

2

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.