Skip to content

Instantly share code, notes, and snippets.

@tott
Created November 16, 2019 00:04
Show Gist options
  • Save tott/9da019907dc123e3fc7378af39677a63 to your computer and use it in GitHub Desktop.
Save tott/9da019907dc123e3fc7378af39677a63 to your computer and use it in GitHub Desktop.
Execute WP-Cron on multisite through wp-cli
#!/bin/bash
function run_cron_due_now {
for SITE_URL in $(wp --allow-root site list --fields=url --format=csv | tail -n +2 | sort); do
wp --allow-root cron event run --due-now --url="$SITE_URL" && echo -e "\t+ Completed Crons for $SITE_URL" &
done
wait $(jobs -p)
echo "Done"
}
run_cron_due_now
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment