Support » Developing with WordPress » wp cron is not visible

  • Cron is not visible in neither in WP Crontrol plugin nor in database.
    I checked Woocommerce->settings and in wordpress environment section I can see that WordPress CRON is enabled.

    This is the code i added to my child’s theme functions.php:

    
    if ( ! wp_next_scheduled( 'popup_cron_hook' ) ) {
        wp_schedule_event( time(), 'every_minute', 'popup_cron_hook' );
    }
    
    add_action( 'popup_cron_hook', 'popup_cron_hook_ex' );
    function popup_cron_hook_ex(){
        $options = get_random_brand_images(6);
        update_option('popuplt_popular_brands', $options, false);
    }

    every_minute schedule is added in woocommerce action-scheduler class by authors:

    	public function add_wp_cron_schedule( $schedules ) {
    		$schedules['every_minute'] = array(
    			'interval' => 60, // in seconds
    			'display'  => __( 'Every minute', 'woocommerce' ),
    		);

    Why my cron is not working?

Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    I think every minute may be too frequent. IIRC the recommended minimum interval is 10 minutes. If you need better performance you should probably use true server CRON jobs. WP Cron is not a true CRON job, it relies on visitor requests to trigger it. Even when you schedule every 10 minutes, if you don’t have adequate traffic to trigger the event it may miss some events. Also, events will not trigger exactly on the 10 minute mark since a request first must come in before anything can happen.

Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.