diff --git a/sbin/wp-cron.sh b/sbin/wp-cron.sh index 202ae27..c20b546 100755 --- a/sbin/wp-cron.sh +++ b/sbin/wp-cron.sh @@ -10,13 +10,13 @@ if [ "$USER" != "root" ]; then exec sudo $0 fi -# create empty virtualhostExclusionArray array (any domains added to this array will be skipped) -declare -a virtualhostExclusionArray - # create virtualhostArray listing all virtualhost on the server cd /srv/www virtualhostArray=(`ls -1|grep -v ^html$`) +# create empty virtualhostExclusionArray array (any domains added to this array will be skipped) +declare -a virtualhostExclusionArray + # check for local config, which can be used to override either of the above arrays if [[ -f /usr/local/etc/wp-cron.conf ]]; then source /usr/local/etc/wp-cron.conf @@ -33,12 +33,13 @@ do if [ -f /srv/www/$VHOST/html/wp-config.php ]; then VHOST_USER=$(stat -c '%U' /srv/www/$VHOST) # confirm that WP really is installed - if $(su -c "wp core is-installed --path=/srv/www/$VHOST/html/" $VHOST_USER); then + if $(timeout 5 su -c "wp core is-installed --path=/srv/www/$VHOST/html/" $VHOST_USER); then # run cron for VHOST as VHOST_USER /usr/bin/logger --tag wp-cron "running wp-cli cron for $VHOST as $VHOST_USER" su -c "/usr/local/bin/wp cron event run --due-now --quiet --path=/srv/www/$VHOST/html/" $VHOST_USER + else + echo "NOTICE: 'wp core is-installed' failed for $VHOST (user $VHOST_USER)" | mail -s "wp-cron" webmaster -aFrom:webmaster fi fi fi done -