Can I Update the Frequency of a Cron Job Through API in a Workflow?

This topic was automatically generated from Slack. You can find the original thread here.

Hello PD community :wave: I have workflows with time triggers (cron jobs running every x hours) and I would like to update through API the frequency of the cron job through another workflow. Is that something that can be done currently?

Hey , Unfortunately, there’s no built in Pipedream feature allow you to do that

You could work something out manually using the data store to save the current schedule, and workflow delays to orchestrate it.

It could work something like this:
• workflow runs
• at the end, check the current schedule in the data store (ex: every 2 hours)
• delay workflow 2 hours (or whatever the schedule is)
• after the delay, trigger itself (via HTTP trigger)
With a setup like that, you would remove the schedule trigger from the workflow, and instead let the workflow trigger itself endlessly based on the schedule from the data store (which you can update via API).

It’s kinda like a recursive function (with a sleep to account for the schedule).

But you gotta be careful not to trigger multiple recursions simultaneously!