wp_scedhule_event not working

I have had a look at all the other posts about this online but can not get this to work. I have set up some custom times and then a custom schedule but it is just not working. Here is my code.

//set up 5 minute schedling and 30 minutes.
function my_cron_schedules($schedules){

        $schedules["5min"] = array(
            'interval' => 300,
            'display' => __('Once every 5 minutes'));

        $schedules["30min"] = array(
            'interval' => 1800,
            'display' => __('Once every 30 minutes'));

    return $schedules;

register_activation_hook(__FILE__, 'my_activation');

function my_activation() {
    if (! wp_next_scheduled ( 'my_5min_event' )) {
    wp_schedule_event(time(), '5min', 'my_5min_event');

add_action('my_5min_event', 'update_db_every_5mins');

function update_db_every_5mins() {
    // do something every 5 minutes

            $wpdb->insert("XXXXX_coin_data", array(
            "datetime" => date("Y-m-d H:i:s"),
            "symbol" => 'QQQ',
            "name" => 'EEEE',
            "price" => 'EEEEEEEEE',
            "market_cap" => 124545,
            "1h_change" => 245345245,
            "24_change" => 452452,
            "7d_change" => 45245245,
            "rank" => 0000000,

//Clear the 5 minute event after it has run
register_deactivation_hook(__FILE__, 'my_deactivation');

function my_deactivation() {

I have used this to see if the event is in the array but it never is and it also never runs.

echo '<pre>'; print_r( _get_cron_array() ); echo '</pre>';

I wonder if I am missing something? I want to get the event working, so I can swap to the server cron and then wget the /wp-cron.php every 5 minutes. The cron on the server is running every 5 minutes but even running WP cron manually is doing nothing. So I want to fix it so I can then move it to properly be automated.

Read more here: wp_scedhule_event not working

Leave a Reply

Your email address will not be published. Required fields are marked *