Wordpress cron jon每6个小时一次

时间:2017-09-29 23:12:13

标签: php wordpress cron-task

我目前每小时都有一个Cron Job设置。我实际上想要改变它每6个小时运行一次。我找不到“六小时”的设置。我错过了什么吗?

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

1 个答案:

答案 0 :(得分:1)

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

允许您设置自定义计划。

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

有这个例子:

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' );