What would be a good way to define two (or more) cronjobs without creating multiple modules?

As far as I know, in order to define a new cronjob, a hook_cron needs to be used like following:

function example_cron(){}

However, I have come to the point where I need to create new cronjob (in order to set different launch times using Ultimate Cron).

At first I looked at Ultimate Cron module and it's hook_cronapi hook as in documentation. However, that and other hooks doesn't really work - https://www.drupal.org/node/2842834

How should I implement it without creating additional modules and using hook_cron's?


As commented in that that issue and various others before, custom cron jobs are defined using config entities, in the same way that ultimate cron defines the default cron jobs.

Just export what you have by default, copy one and adjust the callback/cron configuration, then import it again or define them in your config/install folder for a new module.

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.