This repository has been archived by the owner on Jun 28, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add script for us to manage our own cron jobs via WP CLI
- Loading branch information
1 parent
39796d5
commit b279d5c
Showing
2 changed files
with
20 additions
and
0 deletions.
There are no files selected for viewing
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
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
10
web-servers/staging.spiritedmedia.com/run-all-wp-cron-events.sh
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
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; |