Created
December 9, 2015 13:00
-
-
Save bjornjohansen/f9fe0367eabcc6e37921 to your computer and use it in GitHub Desktop.
Run cron events for all sites in a WordPress multisite network
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
WP_PATH="/path/to/wp" | |
for SITE_URL in $(wp site list --fields=url --archived=0 --deleted=0 --format=csv --path="$WP_PATH" | sed 1d) | |
do | |
for EVENT_HOOK in $(wp cron event list --format=csv --fields=hook,next_run_relative --url="$SITE_URL" --path="$WP_PATH" | grep now$ | awk -F ',' '{print $1}') | |
do | |
wp cron event run "$EVENT_HOOK" --url="$SITE_URL" --path="$WP_PATH" --quiet | |
done | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment