Skip to content

Instantly share code, notes, and snippets.

@mauriciogofas
Forked from faishal/wp-mu-cron.sh
Created August 25, 2023 19:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mauriciogofas/4e31f5620a9f04dc61649998caf7adae to your computer and use it in GitHub Desktop.
Save mauriciogofas/4e31f5620a9f04dc61649998caf7adae to your computer and use it in GitHub Desktop.
Wordpress Multisite Crontab using WP-CLI
WP_PATH="/var/www/site_path"
for SITE_URL in = $(wp site list --fields=domain,path,archived,deleted --format=csv --path="$WP_PATH" | grep ",0,0$" | awk -F ',' '{print $1 $2}')
do
echo $SITE_URL
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
echo $EVENT_HOOK
wp cron event run "$EVENT_HOOK" --url="$SITE_URL" --path="$WP_PATH" > /dev/null 2>&1
done
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment