Other than setting up a cron job, does Craft include any functionality for plugins to run a function at a specific time and/or date?

Some actions could include:

  • Bulk activate/deactivate entries
  • Messaging all users every monday (or once a week)
  • Hitting an API (account update, eCommerce, data updating etc.)

Let me know if a question like this already exists. I searched and couldn't find any related information.

  • Even I have managed to get anonymous Controller actions working as web hooks for cron. So while it may not be the answer you're looking for, it's pretty easy to get your Craft plugin to respond to requests.
    – Matt Stein
    Jul 14 '14 at 16:43
  • Thanks @MattStein - I've used those too. Just looking to program something that fires off at a specific time every day/week. Jul 14 '14 at 17:23

Not really, and it'd be pretty difficult for PHP to truly emulate a cron service since, by nature, it requires something to execute it before it can run (in Craft's case, a browser request).

The closest thing in Craft would be its "Tasks" (completely undocumented). Tasks are usually meant for things that might take a long time for PHP to complete and it's not critical that they happen right away.

But you can't schedule, them... if there is a task in a "pending" state in the craft_tasks table, the next request to the control panel is going to trigger it.

I suppose we could add something like a "runDate" property to tasks where you could be at least guaranteed they wouldn't run until the first control panel request was made after that given date.

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.