Skip to content
This repository has been archived by the owner on Jun 28, 2019. It is now read-only.

Commit

Permalink
Add script for us to manage our own cron jobs via WP CLI
Browse files Browse the repository at this point in the history
  • Loading branch information
kingkool68 committed Oct 26, 2016
1 parent 39796d5 commit b279d5c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
10 changes: 10 additions & 0 deletions web-servers/spiritedmedia.com/run-all-wp-cron-events.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#! /bin/bash
# Use WP CLI to manage our own cron jobs
# Should be triggered by a cron job like so:
# * * * * * /var/www/spiritedmedia.com/scripts/run-all-wp-cron-events.sh > /dev/null 2>&1
#
# Be sure to disable WordPress' own cron system by setting define('DISABLE_WP_CRON', true); in wp-config.php
#
# via http://wordpress.stackexchange.com/a/239257/2744

function run_all_crons_due_now { for SITE_URL in $(wp site list --fields=url --format=csv --allow-root | tail -n +2 | sort); do wp cron event run --due-now --allow-root --url="$SITE_URL" && echo -e "\t+ Finished crons for $SITE_URL" & done; wait $(jobs -p); echo "Done"; }; cd /var/www/spiritedmedia.com/htdocs; run_all_crons_due_now;
10 changes: 10 additions & 0 deletions web-servers/staging.spiritedmedia.com/run-all-wp-cron-events.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#! /bin/bash
# Use WP CLI to manage our own cron jobs
# Should be triggered by a cron job like so:
# * * * * * /var/www/staging.spiritedmedia.com/scripts/run-all-wp-cron-events.sh > /dev/null 2>&1
#
# Be sure to disable WordPress' own cron system by setting define('DISABLE_WP_CRON', true); in wp-config.php
#
# via http://wordpress.stackexchange.com/a/239257/2744

function run_all_crons_due_now { for SITE_URL in $(wp site list --fields=url --format=csv --allow-root | tail -n +2 | sort); do wp cron event run --due-now --allow-root --url="$SITE_URL" && echo -e "\t+ Finished crons for $SITE_URL" & done; wait $(jobs -p); echo "Done"; }; cd /var/www/staging.spiritedmedia.com/htdocs; run_all_crons_due_now;

0 comments on commit b279d5c

Please sign in to comment.