Hey, folks! I run a multi-site installation of Drupal -- what this means is that the domains running Drupal all point to the same installation, but use separate settings files.
The settings files are located in the /public_html/directory, in subdirectories corresponding to the domain; for example:
example.com
example2.com
blog.example3.com
example.com.subdir
As the last two show, Drupal can supply unique settings at the subdomain and subdirectory (example.com/subdir) level.
Part of the setup of Drupal includes configuring cron to execute cron.php on an hourly schedule. For a multi-site installation, it makes sense to use a single script to run cron.php for each domain:
cron-all.pl
(The "all" and "default" directories are ignored in the sites directory.)PHP Code:#!/usr/bin/perl -w
use strict;
my $sites_dir = "/path/to/my/drupal/sites";
my @sites;
system("lynx -source http://example.com/cron.php\n");
if(opendir(SDIR, $sites_dir)) {
@sites = grep { /^[^\.]/ && -d $sites_dir."/".$_ } readdir(SDIR);
for(my $c=0;$c<$#sites+1;$c++) {
if (($sites[$c] ne 'all') && ($sites[$c] ne 'default')) {
system("lynx -source http://".$sites[$c]."/cron.php\n");
}
}
closedir(SDIR);
} else {
print("Could not open sites dir: ".$sites_dir."\n");
}
exit(0);
A problem occurs when the site is in a subdirectory: example.com.subdir obviously isn't going to resolve. Does anyone have any suggestions for determining if $sites[c] is routable and, if not, stripping off the last segment and using it as a directory? TIA!
Don




Bookmarks