#can i stop scheduled functions via cli?
4 messages · Page 1 of 1 (latest)
Hi @vestal marsh. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
Yes, you can stop (cancel) scheduled functions via the CLI in Convex. You can use the function ID returned when scheduling the function and call the cancel operation programmatically, or you can implement a mutation to perform the cancellation and invoke it using the CLI. For example, you could define a mutation like this:
export const cancelMessage = mutation({
args: {
id: v.id("_scheduled_functions"),
},
handler: async (ctx, args) => {
await ctx.scheduler.cancel(args.id);
},
});
Then, you can call this mutation from the CLI using npx convex run and passing the appropriate arguments. The cancellation will prevent the scheduled function from running if it hasn't started yet; if it has already started, it will continue running, but any new functions it tries to schedule will be canceled Canceling scheduled functions.
There is no direct built-in CLI command solely for canceling scheduled functions, but this pattern allows you to achieve the same result.
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
@vestal marsh Kapa.ai is still learning and improving, please let me know how I did by reacting below.