On a Drupal 6 multisite install, whats the best way to have cron run for the requested site only? Going to http://www.mysite.com/cron.php results in a 404.
+1
A:
I think you answer is to do something with the hook_cron() hook. You can specify the site in the database query.
This is some code implementing it:
<?php
function hook_cron() {
$result = db_query('SELECT * FROM {site} WHERE checked = 0 OR checked
+ refresh < %d', time());
while ($site = db_fetch_array($result)) {
cloud_update($site);
}
}
?>
stolen from http://api.drupal.org/api/function/hook_cron
I know this isn't the answer that you were looking for but I think it is in the right direction. I'm a week into drupal. I think I like it ;)
pferdefleisch
2010-08-09 14:17:29
Actually, I see that someone renamed cron.php to cron.bk a long time ago because they are using supercron.php instead. I will change my cronjob on the server to that file, and see what happens. THanks.
Kevin
2010-08-09 14:26:55
+1
A:
cron.php
is the right way, even in multisite installs: Drupal checks HTTP_HOST to see which site to bootstrap into. You mentioned in a comment that it was renamed: besides either renaming or running a cron job on the renamed file, you could also run it from the Status Report page or via Drush:
/usr/bin/php /path/to/drush.php -v -l http://example.com -r /path/to/drupal/ cron
Or simply
drush -l http://example.com cron
if you have your paths set up right for cron.
Mark Trapp
2010-08-09 21:29:06
They are using the Supercron module though, which uses supercron.php. This is a project I inherited and was told not to change anything.. will it be alright leaving it as is?
Kevin
2010-08-09 21:44:01
The only thing I can think of is that something is attempting to hit cron.php directly (e.g. a cron job), but everything internal to Drupal (including Contrib modules) should be using `hook_cron()`, not fetching or doing anything to `cron.php` directly. You should be fine.
Mark Trapp
2010-08-09 21:51:07