Search code examples
phpwordpresscron-task

Wordpress cron jon every 6 hours


I currently have a Cron Job setup to run every hour. I actaully want to change it to run every 6 hours. I could not find a "sixhourly" setting. Am i missing something?

if (!wp_next_scheduled('retrySysProHook')) {
wp_schedule_event(time(), 'hourly', 'retrySysProHook');
}

Solution

  • https://developer.wordpress.org/reference/hooks/cron_schedules/

    Allows you to set custom schedules.

    https://wordpress.stackexchange.com/questions/179694/wp-schedule-event-every-day-at-specific-time

    Has this example:

    function myprefix_custom_cron_schedule( $schedules ) {
        $schedules['every_six_hours'] = array(
            'interval' => 21600, // Every 6 hours
            'display'  => __( 'Every 6 hours' ),
        );
        return $schedules;
    }
    add_filter( 'cron_schedules', 'myprefix_custom_cron_schedule' );