Take the 2-minute tour ×
Craft CMS Stack Exchange is a question and answer site for administrators, end users, developers and designers for Craft CMS. It's 100% free, no registration required.

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.

share|improve this question
    
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 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. –  Adam McCombs Jul 14 at 17:23

1 Answer 1

up vote 4 down vote accepted

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.