How to Write Multiple Cron Jobs in a Single Scenario?

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

How can I write multiple cron jobs in the same one?
I don’t want to create a different scenario for each, possible?


can you show me how to use multiple triggers with one workflow?

For example:

Sunday-Thursday at 10am, 2pm,5pm

Currently, you cannot use multiple triggers directly within a single workflow in Pipedream. However, you can achieve a similar effect by using emitted events to chain multiple workflows together. Here’s how you can configure one workflow to listen for emitted events from another workflow: 1. Create a new workflow with an HTTP / Webhook trigger. This workflow will be the listener. 2. Create another workflow, which will be the emitter. In this workflow, you’ll use $.send.emit() to emit events. 3. Get the workflow IDs of both the listener and emitter workflows. You’ll find the workflow ID in the workflow’s URL in your browser bar — it’s the p_abc123 in 4. Use the Pipedream REST API to configure the listener to receive events from the emitter. This is called creating a subscription. If your listener’s ID is p_abc123 and your emitter’s ID is p_def456, you can run the following command to create this subscription: bash curl \ -H "Authorization: Bearer {api_key}" \ -H "Content-Type: application/json" \ -d '{"emitter_id": "p_def456"}' Replace {api_key} with your Pipedream API key. By chaining workflows together using emitted events, you can effectively use multiple triggers with one workflow. The emitter workflows will act as different triggers, and the listener workflow will process the events from those triggers.

Hmm Mario needs to be taught this better I suppose

But yes you can define multiple triggers for one workflow: Triggers

0 10,14,17 ** ** 0-4
“At minute 0 past hour 10, 14, and 17 on every day-of-week from Sunday through Thursday.”


Or if you know cron-fu like Alyson you can do it with just one :wink:

I like this tool to test crons:

Thanks guys.
I liked what Alyson showed.

Easy solution

How can I add a timezone as well please?

how do I add a timezone to a cron job definition?

To add a timezone to a cron job definition in Pipedream, you can use the tz property when setting up the cron trigger. Here’s an example of how to set up a cron trigger with a timezone: export default { name: "My Cron Workflow", triggers: { cron: { type: "$.interface.timer", customGranularity: "**/5 ** ** ** **", tz: "America/Los_Angeles", }, }, async run(event) { console.log("Cron job triggered with timezone America/Los_Angeles"); }, }; In this example, the cron trigger is set to run every 5 minutes, and the timezone is set to “America/Los_Angeles”. You can replace the timezone with the desired timezone from the IANA Time Zone Database (List of tz database time zones - Wikipedia). Remember to replace the cron expression ("**/5 ** ** ** **" in the example) with your desired cron expression, such as "0 10,14,17 ** ** 0-4" for your specific use case of running the workflow on Sunday-Thursday at 10am, 2pm, and 5pm.

I believe that you can only set one timezone, using the prop Timezone on Cron Schedule trigger

And if I need a different for each then I must create a different scenario correct?

yes, but you can use multiple triggers, in the same workflow

But I can choose one, isn’t or from my understanding

if you add multiple triggers, each one will activate the workflow based on the current source criteria, see this working example: