WP CRON runs only the first time

OK, so I’ve tested your code and I’m pretty sure it can’t run even once… And here’s why… If you’ll take a look at wp_schedule_event you’ll see this check at the top of the function: if ( !isset( $schedules[$recurrence] ) ) return false; It means that you can’t schedule event with unknown recurrence. So let’s … Read more

Do wp-cron scheduled tasks run asynchronously?

No, the WP-Cron tasks run asynchronously from the viewing user. They should not see any delay. Although if your task takes more than a minute, it may never finish since most hosts are setup to kill PHP processes after 30 seconds.

Running wp-cron from CLI

Or, you could use WP-CLI which was developed for scenarios like these. After a short installation like this $ curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar $ chmod +x wp-cli.phar $ sudo mv wp-cli.phar /usr/local/bin/wp You can run your scheduled tasks like so $ wp cron event run –due-now –path=/var/www/mywebsite.com/ or via crontab (every 5mins) */5 * * * … Read more

Missed scheduled WordPress

Due to your server configuration, you may need to use the alternate cron method, which uses redirect rather than http loopback. Try adding the following to your wp-config.php file: // Alternate cron method define( ‘ALTERNATE_WP_CRON’, true );

wp_next_scheduled returning a past timestamp

Well, as I was working on an existing site which as maaaaany plugins already installed, I figured out that there was a define(DISABLE_WP_CRON,true); So when you seems to have the same problem than me. Do a research of define(DISABLE_WP_CRON,true); in your files.

wp_schedule_event() on specific time, daily

time() only returns current time, it doesn’t accept any inputs. $time = time(); // works out to 2016-04-11T12:11:34+00:00 What you want is midnight tomorrow: $tomorrow = strtotime( ‘tomorrow’ ); // works out to 2016-04-12T00:00:00+00:00 Note that these are PHP functions and they ignore WP timezone, since it resets PHP time zone to UTC. So if … Read more