Sunday, January 17, 2010

drupal cron for multiple sites

There are times when we have multiple site to maintain for our drupal based websites.
One way to do it is by doing a shell script.
But i would prefer to do it using php script instead:

runcron.php
------------------------

$aSites = array(
"http://xyz.com/cron.php",
"http://example.com/cron.php"
);
foreach( $aSites as $sSite ):
$sContent = file_get_contents($sSite);
echo "Retrieved: " . $sSite . "\r\n
";
echo substr($sContent,0, 100) . "...\r\n
";
endforeach;

-------------------
And setup the cron in cpanel:
php [path_to_your_php]/runcron.php
etc.: php /home/example.com/public_html/mydrupal/runcron.php > /dev/null

Hope this is helpful :)

No comments: