【问题标题】:Wordpress cron jon every 6 hoursWordpress cron 作业每 6 小时
【发布时间】:2017-09-29 23:12:13
【问题描述】:

我目前有一个每小时运行一次的 Cron 作业设置。我实际上想将其更改为每 6 小时运行一次。我找不到“每六小时一次”的设置。我错过了什么吗?

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

【问题讨论】:

    标签: php wordpress cron-task


    【解决方案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' );
    

    【讨论】:

    • 我是否将“hourly”替换为“every_six_hours”
    • 何不尝试修改代码,看看会发生什么,我建议尝试做一个5分钟的计时器,然后你就会知道它起作用了。
    猜你喜欢
    • 1970-01-01
    • 2014-05-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-08-09
    • 1970-01-01
    • 2018-02-18
    • 2016-10-31
    相关资源
    最近更新 更多