Can I improve my cron job speed?

Ex: it takes me 30 seconds to complete a certain cron job. Can I make it do this faster?

Does cron speed depend on the server machine?

2 Answers 2


You've to check which modules implement hook_cron and see what's happening during your cron run. It is also useful to run cron from the command like, e.g.

drush -v cron

and check for any screen messages or Drupal logs (drush ws). You may prefix your command with strace -f/dtruss to debug the command processing.

Check also if manually calling cron.php via curl would help, e.g.:

time curl -v "http://example.com/cron.php?cron_key=XYZ"

especially on your local server, then eventually check via tcpdump if you've any outgoing connections or it's CPU/resource thing.

Here are few common reasons which can give you some ideas:

  • you've some network timeouts (try disabling Update module, check firewall/proxies),
  • you're executing cron in the wrong way, see: Setting up cron,
  • you've too many modules enabled which overusing hook_cron,
  • you've some migration going in the background (e.g. Migrate module), so you may decrease number of items to process in the settings,
  • you don't have any caching implemented (check your OPCache/XCache configuration), enable memcached, see: How do you improve Drupal performance?
  • you've unnecessary PHP/Apache modules enabled (e.g. XDebug),
  • your cron task needs more time than 30 seconds, so you may increase your max_execution_time either in php.ini or during your cron run.

Does cron speed depend on the server machine?

Yes, to an extent. Maybe even a large extent, it depends on a lot of different factors.

Can I make it do this faster?

Probably, but that's as much as anyone can tell you from here. Profile the code, see where the bottlenecks are, and fix them. There's no magic formula

  • I upgraded to bigger EC2 instance and the same cron job ran faster, clocked at 21 seconds. =)
    – No Sssweat
    Dec 2, 2015 at 10:07
  • nothing personal, IMO kenorb bested your answer; thus, I am awarding him the green checkmark.
    – No Sssweat
    Dec 16, 2015 at 21:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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