Let your visitors run Drupal cron for you

Submitted by Anonymous (not verified) on Fri, 03/06/2009 - 15:10

Sometimes (or mostly on shared hosts) wo dont have ssh/shell acces to server to configure crontab. In this case we need to run crons manually or register for a paid cron-service or find an other solution. For my solution I need just one visitor a day to request a hidden img-tag. And its working; at least once a day Drupal runs cron.php.

  • Create a block called something like "run cron manually"
  • Activate your block; move to footer region etc
  • Put following code and save as PHP-Filter (input format)

Code for "run cron manually with a footer block"

$now = time();
$last_run = variable_get("cron_last_run", 0);

if( $now-$last_run > 86400 ){
variable_set("cron_last_run", $now);
return "<img src=\"/cron.php\" width=1 height=1 border=0>";
}

Add new comment