0

I want to schedule an action to be run daily. This action can take up to a few seconds.

Question is: is WP-Cron the suitable mechanism (compared to, say, classic Unix cron) for such action?

The reason why I'm asking is that, as far as I understand, all WordPress hooks are triggered by HTTP requests, probably coming from regular visitors or administrators. If the action is run in the same thread as the triggering HTTP request, I'm afraid the later will be affected by the scheduled action. Bottom line: once per day, an unlucky visitor might notice a huge delay while accessing the site.

So can I register my action with wp_schedule_event? If so, could you describe how WordPress works around this issue? If not, what are the options? I really don't want to deal with cron directly, plus my plugin should also work on Windows systems.

0

Apparently, WP-Cron jobs are run in a separate process. This can raise some issues, but at least the answer to the question above is: yes, a time-consuming action can be scheduled with WP-Cron. The triggering HTTP request won't be delayed because of it.

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.