mango/eleeM
Convex Community2y ago
2 replies
mango/elee

Programmatically invoking and cancelling a cron

So...
What I was wondering was whether we could have a way to programmatically schedule a cron when needed and then cancel it and clean it up when done

for example let's say at 6 am I want a function to start/have it's first invocation via an api call and then it checks something a db value or calls another api every 4 minutes, does this for 30 minutes or until desired result is achieved and then is cancelled


one potential alternative is to from a function schedule a recursive action which checks if time is over 30 minutes or desired result has been achieved if not it schedules itself for after 4 minutes and does this recursively➕

so while it can be solved for some reason the cron approach seems better especially for example if someone wants to run a function each 5 seconds but not infinitely and only when triggered

what do others feel?
Was this page helpful?