Experts,
Currently in one of my wordpress plugins there is a cron which runs as per schedule below. wp_schedule_event( time(), 'hourly', 'w4pr_cron' ); I would like to change this to run every 5 minutes in a particular time range.
For E.g. The current code as you know will run once every hour in a day. (24 runs in a day). I would like this to run every 5 minutes between 5:00am and 6:30am (EST) only (18 runs in a day).
Any help appreciated!
Thanks Thomas
You would first need to add the custom cron schedule for it to run every 5 minutes
However, to only allow it to run within the certain time frame without causing extra overhead you may be better off schedule each specific event.
The other option would be to put logic in the trigger to only run your functions during the specified time frame, but that would cause extra overhead on high traffic sites where the cron would be firing every 5 minutes.
First create a custom interval, you can find more information about this here.
Make sure that you have unscheduled the event registered by the plugin:
Next schedule an event with this interval of recurrence to begin at 5 AM:
w4pr_cron is not a function, but a hook which has functions attached to it. So what you want to do is make sure nothing happens when this hook is called on if the timestamp is not within your given time interval. So in functions.php or somewhere which will see it executed on every page load, put: