• Failed to save the cron event custom_wishlist_cron_job

    i’m trying to create new event to send email and when i add hook name and click save the above error occurs, and cannot add event.

    i’m working on localhost, also i have tried on live site to create but same error occurs there too.

Viewing 12 replies - 1 through 12 (of 12 total)
  • Plugin Author John Blackbourn

    (@johnbillion)

    WordPress Core Developer

    Unfortunately WordPress core doesn’t expose the underlying reason for the failure when creating a cron event fails.

    Can you try creating the event with WP-CLI or creating it in code with wp_schedule_event() and see if it works?

    Thread Starter kabeerhussain14

    (@kabeerhussain14)

    I tried to create using wp_schedule_event() but that crons not visible in the list of events.

    add_action('init','create_custom_cron_test');
    function create_custom_cron_test(){
    	if (!wp_next_scheduled('wishlist_cron_job_test_fun')) {
    		//wp_schedule_event(time(), 'hourly', 'test_wishlist_cron_job');
    		wp_schedule_event(time(), 'every_three_minutes', 'wishlist_cron_job_test_fun');
    		// wp_schedule_event(strtotime('22:00:00'), 'daily', 'test_wishlist_cron_job');
    	}
    }
    Plugin Author John Blackbourn

    (@johnbillion)

    WordPress Core Developer

    There could be an issue with the object cache on your site.

    * Can you try scheduling the event for the future, instead of time()? Eg. schedule it for one minute’s time (time() + MINUTE_IN_SECONDS).
    * Can you try scheduling it with a longer recurrence? Eg .daily instead of every_three_minutes.

    Thread Starter kabeerhussain14

    (@kabeerhussain14)

    Yes for now i’m testing that’s why i added 3 minutes,
    i will extend the time to every day after testing.

    Plugin Author John Blackbourn

    (@johnbillion)

    WordPress Core Developer

    Do you have an object cache plugin on your site? Can you try deactivating it if so?

    Thread Starter kabeerhussain14

    (@kabeerhussain14)

    Yes its showing when i changed the time time()+60.

    Thanks

    Plugin Author John Blackbourn

    (@johnbillion)

    WordPress Core Developer

    Ah I’ve seen this problem before. I think scheduling a job for time() can be unreliable. I’ll see about adding a fix to WP Crontrol to add a few seconds to the time if the user chooses “Now” for the event.

    It doesn’t fix the underlying problem in WordPress but it’ll fix it in WP Crontrol.

    Cheers

    Plugin Author John Blackbourn

    (@johnbillion)

    WordPress Core Developer

    @kabeerhussain14 Does your code work if you add just 1 second to the time?

    Thread Starter kabeerhussain14

    (@kabeerhussain14)

    The issue is not with the time() issue was with the minutes that i wrote, means every_three_minutes is i guess not defined,

    wp_schedule_event(time(), 'daily', 'wishlist_cron_job_test');

    this is also showing me the cron

    Thread Starter kabeerhussain14

    (@kabeerhussain14)

    The main issue is with the second parameter

    I’ll see about adding a fix to WP Crontrol to add a few seconds to the time if the user chooses “Now” for the event.

    @johnbillion We are seeing that exact issue after the refactor. We select “Now” for one-off tests or tasks, so it’s infrequent but still used.

    I also had the same problem today. I also selected to run now.
    see: https://jmp.sh/PqPOY3L

    When I selected At: and informed today’s date, but 15 minutes more, it allowed to register, without errors.

    There was also a strange error, when in the list of events I clicked the run now link. The Next Run column changed to 1969-12-31 21:00:01. That is 50 years ago
    See attached screen: https://jmp.sh/YssZSAB

    I’m just reporting the occurred. I hope to be helping.

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘Add New Cron Job (ERROR)’ is closed to new replies.