0

I have a custom module where I create several cron tasks using HOOK_cronapi. This is done when the user visits a page and has a form to create those tasks.

I also need that the user can disable those tasks but I can't find anything in the elysia cron documentation on how to disable a cron job.

After it is created I can't disable it programmatically? (I can do it via GUI)

Thanks.

  • 1
    Why not use if (variable_get('some_var', FALSE)) { ... in hook_cronapi()? – Clive May 11 '15 at 15:35
  • Nice idea Clive. I think that may solve my problem. Anyway, there should be an option to enable/disable the task. – zephirus May 11 '15 at 17:15
  • There doesn't seem to be an option for one per task, but you could create a channel just for those jobs, and then disable the channel (which there is an option for) – Clive May 11 '15 at 17:19
  • Clive, do you know how can I enable/disable the channel in my module? I don't see that option either. – zephirus May 11 '15 at 18:21
  • elysia_cron_set_channel_disabled('channel_name', TRUE); should do it (or FALSE to enable) – Clive May 11 '15 at 18:28
0

I realize this is pretty old but if you are only concerned with one task and not a whole channel...

elysia_cron_set_job_disabled('mymodule_cron', true);

will disable a cron job. Not surprisingly,

elysia_cron_set_job_disabled('mymodule_cron', false);

enables it again.

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.