crontab -e
WordPress Crons running with WP-CLI each 15 minutes with :
Var | Type | Description |
---|---|---|
{path_to_wp} | string | path to the WordPress root folder |
{path_to_php} | string | path to php |
{path_to_wp_cli_phar} | string | path to the wp-cli.phar package. Using our project Skafold, it's generally `{wp_content_folder}/tools/wp-cli.phar`. If you have wp cli installed, just use `wp`. |
{wp_content_folder} | string | depending on if project is running with composer or not : content or wp-content |
*/15 * * * * cd {path_to_wp} && {path_to_php} {path_to_wp_cli_phar} cron event run --due-now
Exemples:
*/15 * * * * cd /home/public_html/ && php71 content/tools/wp-cli.phar cron event run --due-now
For WooCommerce Action Scheduler (https://actionscheduler.org/wp-cli/):
*/5 * * * * php tools/wp-cli.phar action-scheduler run
*/15 * * * * cd {path_to_wp} && {path_to_php} {path_to_wp_cli_phar} site list --field=url | xargs -i -n1 {path_to_php} {path_to_wp_cli_phar} cron event run --due-now --url="{}"
Exemple:
*/15 * * * * cd /home/public_html/ && php71 wp-cli.phar site list --field=url | xargs -i -n1 php71 wp-cli.phar cron event run --due-now --url="{}"
// Ensure WP Cron are disabled into wp-config
define( 'DISABLE_WP_CRON', true );
Other writing :
for url in $(wp site list --field=url --url=); do wp option get siteurl --url=$url; php wp cron event run --due-now --url=$url; done;