Community Documentation

Multi-site Cron Bash Script

Last updated May 8, 2009. Created by ryanaghdam on May 4, 2009.
Log in to edit this page.

A quick bash script to run cron for multiple sites:

#!/bin/bash

## Define your websites in an array
sites=(example.com example2.com example3.com)

len=${#sites[*]}
for((i=0; i<$len; i++)); do
        wget -q http://${sites[${i}]}/cron.php
        # You may remove (or comment) the following line if you
        # wish to retain the downloaded file.
        rm cron.php
done

Comments

Another Script

This is a script i wrote if you have your named server on the same machine.
You don't have to write every site you have.
Please test it first by putting an echo in front of the wget line.

#!/bin/sh
# Execute cron.php for all sites on server
# Kyriakos 25/2/2010

sites=`cat /etc/named.conf | grep zone | awk -F "\"" '{print $2}'`
for site in $sites
do
if [ "$site" = "." ]
then
continue
fi
wget -O - -q -t 1 http://www.$site/cron.php
echo "Site $site done"
done