1

I am trying to trigger a function using cron job in a time interval of 1 minute but it is not working, am I missing something?

register_activation_hook(__FILE__, 'my_event_recurring_activation'); function my_event_recurring_activation() { if (! wp_next_scheduled ( 'recurring_event' )) { wp_schedule_event(time(), 'every_minute', 'recurring_event'); } } add_action('recurring_event', 'do_this_daly'); function do_this_daly() { update_acf_field_programmatic(); } 
1
  • Not working is very hard to diagnose. Can you edit your question to say what the expected behaviour was and what your actual result was, please? Also, FYI, WP cron only triggers if there is activity on the site at the time. One solution is to set your hosting to trigger a real cron and load a page with wget or whatever. Commented Dec 13, 2023 at 10:15

1 Answer 1

1

The default supported recurrences are ‘hourly’, ‘twicedaily’, ‘daily’, and ‘weekly’. From the WordPress definition https://developer.wordpress.org/reference/functions/wp_get_schedules/

If you're using wp_schedule_event(time(), 'every_minute', 'recurring_event');, you may need to change the recurrence parameter to one of the correct options mentioned above. Refer to the documentation for guidance.

To check and trigger your Cron function, you can use a plugin like WP Crontrol. This plugin allows you to manage and monitor your WordPress cron jobs, helping you identify any errors in your code.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.