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 totally confused with this. Even after setting new intervals, cron function runs on previous time intervals only.
What might be the reason for this, kindly help me out on this.
This is my code:
add_filter('cron_schedules', 'filter_cron_schedules');
function filter_cron_schedules($schedules) {
$schedules['fifteen_minutes'] = array(
'interval' => 900, // seconds
'display' => __('Every 15 minutes')
);
$schedules['twenty_minutes'] = array(
'interval' => 1200, // seconds
'display' => __('Every 20 minutes')
);
$schedules['three_days'] = array(
'interval' => 259200, // seconds
'display' => __('Every 3 days')
);
$schedules['five_minutes'] = array(
'interval' => 300, // seconds
'display' => __('Every 5 minutes')
);
return $schedules;
}
// Schedule the cron
add_action('wp', 'bd_cron_activation');
function bd_cron_activation() {
if (!wp_next_scheduled('bd_cron_cache')) {
wp_schedule_event(time(), 'twenty_minutes', 'bd_cron_cache'); // hourly, daily, twicedaily
}
}
// Firing the function
add_action('bd_cron_cache', 'bd_data');
function bd_data() {
// My Logic
}