Skip to content

Instantly share code, notes, and snippets.

@bjornjohansen
Created December 9, 2015 13:00
Show Gist options
  • Save bjornjohansen/f9fe0367eabcc6e37921 to your computer and use it in GitHub Desktop.
Save bjornjohansen/f9fe0367eabcc6e37921 to your computer and use it in GitHub Desktop.
Run cron events for all sites in a WordPress multisite network
#!/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