CRON JOB IN DRUPAL MULTISITE
I have 5 sites (Drupal multisites). I would like to perform a script that runs cron.php on all of the 5 sites.
0 0 * * * wget -O - -q -t 1 h**p://site1/cron.php
0 0 * * * wget -O - -q -t 1 h**p://site2/cron.php
...
How can a script analyze domain name and executes i开发者_运维问答n shell command?
Most important is to determine if you need to run Cron at all for all sites. If multisites use the same database there is no need: just run it once for the "main" site.
If you have multiple databases, it is probably still a bad idea to run cron trough a script that runs it for every site, because of performance-tuning and resource availability. If hundred sites all at once open HTTP sockets to pull in the latest tweets, something will choke. Best is to spread this out over the hole our: sixty sites running cron one after another.
That said, here is a bash script. save as /etc/cron.d/drupal
on Debian/Ubuntu machines:
for site in `find /path/to/drupal/sites/ -type d -name '*.*' -printf "%fname\n"`; do
wget -O - -q -t 1 http://$site/cron.php
#you could do a "sleep 60" to wait a minute before calling the next cron here.
done
If your sites directory contains more directories then "all, default and domainname.tld" then you might want to improve the regular expression for find (*.*
).
精彩评论