Strike
CDCloudflare Developers
•Created by Strike on 3/8/2025 in #workers-help
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.
2 replies