• Method to Execute at Certain Interval

    function informant_main_action(){
        die('working');
    }

    Custom Schedule for Cron Job

    function my_cron_definer($schedules){
            $schedules['weekly'] = array('interval'=> 120, //604800
                'display'=>  __('Once Every week')
                );
            return $schedules;
        }

    add_filter('cron_schedules','my_cron_definer');

    Register schedule on plugin activation

    register_activation_hook( __FILE__, 'informant_run_on_activation' );

    function informant_run_on_activation(){
        if(!wp_next_scheduled('informantweeklynewsletter')){
            wp_schedule_event(time(), 'weekly', 'informantweeklynewsletter');
        }
    }

    Calling my method to be executed on custom event

    add_action('informantweeklynewsletter','informant_main_action');

    I have installed a plugin Cron Gui for viewing scheduled cronjob and it is listing my event correctly as i put the recurrence for every two minutes the cron gui shows the correct result i.e its updating the time +2 minutes.

    But my method informant_main_action() is not working. Whats the mistake i am making. ?

    Thanks

  • The topic ‘Cronjob scheduled but not executing.’ is closed to new replies.