Articles of cron

wp_schedule_event action not running

It seems like all the answers on here for this question end up being a syntax error, however I’m not seeing it here. I’m trying to setup a daily job here that will run through all my ‘vacation’ posts, if the _simple_start_date (unix timestamp) is the same date as today, then run some functions to […]

Cancel/Stop a currently ongoing scheduled cron event?

If I scheduled a CPU-intensive job via a cron scheduled event, how do I go about stopping it or cancelling the job while it is currently running?

WordPress cron is running with previously set time intervals and not the updated one

For testing purposes I keep short time intervals for cron and when the functionality is working fine, I change it to the required time interval. Whenever I change the time intervals for ex: from ‘three_days’ to ‘five_minutes’ or from ‘five_minutes’ to ‘fifteen_minutes’, the cron is running with earlier frequency and not the updated one. I’m […]

Cron and WP Super Cache in Preload Mode

I disabled WordPress Cron and configured a real Cron (Linux Cron) to hit wp-cron.php every 8 hours, but I’m not sure how it affects the behavior of WP Super Cache in Preload Mode. As far as I know, WP Super Cache processes 100 posts, takes a break of 10 seconds, processes another 100 posts, takes […]

Using WP_Query and WP_Meta_Query Outside of WordPress

I’m trying to figure out how I can utilize WP_Query and WP_Meta_Query outside of the WordPress install, for server Cron jobs. I’ve tried including wp-load.php but this also brings in plugins like WooCommerce into the mix and I’m getting all kinds of header warnings, etc. I just need to be interacting with the database, not […]

Dynamic name of cron event

In my multisite install, I’d like to add a daily cron event for some of the subsites. The cron will import posts via API from another website. Because importing the content for all sites at once would end in timeout, I’d like to set a cron for each of the subsites. In my class I […]

wp_schedule_event didn't work

It will work if I give specific post id.It didn’t work if I give $post->ID. Why? Here my code: add_action( ‘wp’, ‘delete_expired_coupons_daily’ ); function delete_expired_coupons_daily() { if ( ! wp_next_scheduled( ‘update_expired_post_status’ ) ) { wp_schedule_event( time(), ‘hourly’, ‘update_expired_post_status’); } } function update_expired_field(){ global $post; $postid=$post->ID; $my_post = array( ‘ID’ => $postid, ‘post_status’ => ‘expired’, ); […]

Avoiding “Missed Schedule” errors when inserting future posts

I’m inserting future posts as you’d expect using a post_status of future and a future post_date and post_date_gmt. The dates look fine in WordPress, but these posts appear with the “Missed Schedule” warning. They haven’t missed schedule yet because they’re future posts. My guess is that it’s because when inserting these future posts I’m not […]

External cron job firing too many times

WordPress’ cron jobs seemed to cause some issues on our server, so I added this to the bottom of our wp-config.php: define(‘DISABLE_WP_CRON’, ‘true’); And added this using ‘crontab -e’: */15 * * * * /usr/bin/php /path/to/wordpress/wp-cron.php > /var/log/cronoutput.log If I’m not wrong, the above will have our server execute the WordPress cron jobs every 15 […]

A unique wp_schedule_single_event() for each post?

I’m building a site for a client that requires sending out emails about each post at various dates (i.e. two weeks before after the post was published, then again four weeks after the post was published, etc). It seems that the best way to do this is with wp_schedule_single_event() with a unique event name, but […]