Executing Cron with random delay

I was wondering what the best way would be to have a cron job run every hour and then have some random variance as to when it executes. My idea was to do the following: - setup a cron trigger to run every hour - the worker awaits a promise with a timeout that resolves with some random time (e.g. 30min) - do work (I'm just running a request and storing that into KV) - finish Is there anything that would prevent this from being a feasible idea? Thanks in advance. Maybe I implemented it wrong but when trying this out so far I seem to get "exceeded limits" error.
1 Reply
Walshy
Walshy7d ago
Crons are meant to run at a set schedule. I'd recommend looking at Durable Object alarms instead, you can set do whatever you want there

Did you find this page helpful?