Since the cron is ran during the users' pageload, does it run async, or does it block the request until it's finished?

In the latter case, what would the best practice be not to have the user wait too long. I want to do a few user_delete calls on each cron run (as many as possible without blocking the site). I saw Drupal has some kind of a queue-ing mechanism, but I didn't see any doc about how it's used.


This depends on the way you setup and you are running the cron.

If you enabled the Run cron every field at Admin -> Config -> Cron (admin/config/system/cron) then the cron will be triggered by opening pages on the site, and yes it will affect the page load of visitors.

However, it is recommended to disable the cron on that page and setup a cron task on your server. You can read the article here on how to do that correctly. In this case it is not blocking the site directly, but it will still, partially, affect the visitors who are using the site at the time of execution.
This is because often the cron will look for updates and perform other resource-intensive tasks and there will simply be less server resources available.
For this reason if you need to run the cron only once-twice daily, you run it usually during the night or some other time when you don't have many visitors.

Lastly, check Elysia Cron which allows you to finetune what exactly is executed and how often - it calls selectively hook_cron() of the modules you have on the site.

  • Thanks! Didn't know you also have the option to run real/actual crons :) – Eduard Luca Nov 6 '12 at 18:28

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.