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?
Drupal Answers is a question and answer site for Drupal developers and administrators. It only takes a minute to sign up.
Sign up to join this communityYou'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:
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