wp_schedule_event function reference

I think if you need to call page every hour you can do it with a simple cron (not wp_cron) and set it in your panel or via shell a string like this:

  • */1 * * * wget -O – /path/to/link >/dev/null 2>&1

But if you need to do it via wp

add_action('wp', 'set_cron' );
add_action('test_scheduled', 'fn_test_scheduled');
function set_cron() {
    // Remove any scheduled event on this hook
    //wp_clear_scheduled_hook( 'exercise_reminder' );
    if (!wp_next_scheduled('test_scheduled')) {
        wp_schedule_event( gmmktime(8, 0, 0, 1, 4, 2015), 'hourly', 'test_scheduled');
    }
}
function test_scheduled() {
    $ch = curl_init();

// set URL and other appropriate options
curl_setopt($ch, CURLOPT_URL, "/path/to/link/");
curl_setopt($ch, CURLOPT_HEADER, 0);

// grab URL and pass it to the browser
curl_exec($ch);

// close cURL resource, and free up system resources
curl_close($ch);
}

In this example you need to change gmmktime with your preference

Be careful with wp cron. I suggest you to use it only if it’s a real cron https://tribulant.com/blog/wordpress/replace-wordpress-cron-with-real-cron-for-site-speed/

I hope this help you.
David

error code: 523