Snowflake task scheduling

Viewed 301

I have to write a snowflake task to run everyday at every 2 minutes from 5:00 EST to 5:00 PM EST. The code I wrote is not working, the task didnt stop running even after 5:00 PM:

CREATE OR REPLACE TASK tsk_master
    WAREHOUSE = XS_WH
    SCHEDULE = 'USING CRON * 5-17 * * * America/New_York'
    TIMESTAMP_INPUT_FORMAT = 'YYYY-MM-DD HH24'
COMMENT = 'Master task job to trigger all other tasks'
AS call pntinsight_lnd.SP_ACCT_DIM_1();

Please suggest what did I do wrong, how to stop it from running after 5 PM, and how can i set it to run every 2 minutes?

2 Answers

You have to define all trigger minutes, it looks ugly but it should work:

CREATE OR REPLACE TASK tsk_master
    WAREHOUSE = XS_WH
    SCHEDULE = 'USING CRON 0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50,52,54,56,58  5-17 * * * America/New_York'
    TIMESTAMP_INPUT_FORMAT = 'YYYY-MM-DD HH24'
COMMENT = 'Master task job to trigger all other tasks'
AS call pntinsight_lnd.SP_ACCT_DIM_1();

snowflake task to run everyday at every 2 minutes from 5:00 EST to 5:00 PM EST.

Optional parameters:

/n

Indicates the nth instance of a given unit of time. Each quanta of time is computed independently

So every 2 minutes will be:

SCHEDULE = 'USING CRON */2 5-17 * * * America/New_York'
Related