How to Schedule Jobs in Snowflake

Galaxy Glossary

How do I schedule and automate SQL jobs in Snowflake?

CREATE TASK lets you schedule and automate SQL jobs directly inside Snowflake.

Sign up for the latest in SQL knowledge from the Galaxy Team!
Welcome to the Galaxy, Guardian!
Oops! Something went wrong while submitting the form.

Description

Table of Contents

What is Snowflake job scheduling?

Snowflake schedules jobs with CREATE TASK. A task stores a SQL statement and a cron or interval schedule. Once enabled, Snowflake executes the task automatically without external orchestration.

How does CREATE TASK schedule jobs?

CREATE TASK defines timing through a CRON or USING WAREHOUSE clause. You can trigger tasks by time or by dependency on another task, forming DAG-style pipelines.

What are the key parameters of CREATE TASK?

SCHEDULE or CRON sets run time; WAREHOUSE specifies compute; USER_TASK_MANAGED_INITIAL_WAREHOUSE_SIZE reserves capacity; AFTER chains tasks; WHEN prevents runs unless a boolean expression is true.

How to create a daily order summary task?

Use our ecommerce schema. The task aggregates yesterday’s orders into a reporting table. Enable the task to start the schedule immediately.

CREATE OR REPLACE TASK daily_order_summary
WAREHOUSE = analytics_wh
SCHEDULE = 'USING CRON 0 3 * * * America/Los_Angeles'
AS
INSERT INTO order_metrics (summary_date, total_orders, total_revenue)
SELECT CURRENT_DATE - 1,
COUNT(*),
SUM(total_amount)
FROM Orders
WHERE order_date = CURRENT_DATE - 1;

ALTER TASK daily_order_summary RESUME;

How to chain tasks for complex workflows?

Create downstream tasks with AFTER. Snowflake guarantees that a child task starts only after its parent finishes successfully, simplifying ETL pipelines.

CREATE OR REPLACE TASK refresh_product_sales
WAREHOUSE = analytics_wh
AFTER daily_order_summary
AS
MERGE INTO product_sales USING (
SELECT product_id, SUM(quantity) AS sold
FROM OrderItems
GROUP BY product_id
) src ON Products.id = src.product_id
WHEN MATCHED THEN UPDATE SET stock = stock - src.sold;

ALTER TASK refresh_product_sales RESUME;

How to monitor and troubleshoot tasks?

Query ACCOUNT_USAGE.TASK_HISTORY or INFORMATION_SCHEMA.TASK_HISTORY. Look at LAST_FAILED_RUN_TIME and ERROR_MESSAGE to diagnose problems quickly.

What are best practices for Snowflake job scheduling?

Use dedicated, appropriately sized warehouses. Keep SQL logic idempotent. Store results in separate tables to avoid locking source data. Pause tasks during backfills to prevent double processing.

Common mistakes and fixes

Mis-sized warehouse: A warehouse too small causes long runtimes and task overlap. Fix by setting USER_TASK_MANAGED_INITIAL_WAREHOUSE_SIZE or choosing a larger warehouse.

Forgot to RESUME: CREATE TASK defaults to SUSPENDED. Enable with ALTER TASK ... RESUME, otherwise the job never runs.

FAQ

Can I schedule sub-minute tasks?

No. The shortest interval is 1 minute. Use external orchestration for faster cadence.

How do I stop a task temporarily?

Run ALTER TASK task_name SUSPEND; to pause without dropping.

Does task failure retry automatically?

Snowflake retries once after a system error but not on SQL errors. Build idempotency and error handling into your SQL.

Why How to Schedule Jobs in Snowflake is important

How to Schedule Jobs in Snowflake Example Usage


-- Nightly customer growth snapshot
CREATE OR REPLACE TASK nightly_customer_growth
  WAREHOUSE = analytics_wh
  SCHEDULE = 'USING CRON 0 2 * * * America/New_York'
AS
INSERT INTO customer_growth (snapshot_date, new_customers)
SELECT CURRENT_DATE - 1, COUNT(*)
FROM Customers
WHERE created_at::date = CURRENT_DATE - 1;

ALTER TASK nightly_customer_growth RESUME;

How to Schedule Jobs in Snowflake Syntax


CREATE [ OR REPLACE ] TASK <task_name>
    WAREHOUSE = <warehouse_name>
    [ USER_TASK_MANAGED_INITIAL_WAREHOUSE_SIZE = { XSMALL | SMALL | ... } ]
    [ SCHEDULE = 'USING CRON <cron_expr> <timezone>' | SCHEDULE = '<interval> MINUTE' ]
    [ AFTER = <parent_task_list> ]
    [ WHEN = <boolean_condition> ]
AS
<single SQL statement | CALL stored_procedure()>;

-- Enable the task
ALTER TASK <task_name> RESUME;

Common Mistakes

Frequently Asked Questions (FAQs)

Can I use a serverless warehouse?

Yes. Omit WAREHOUSE and Snowflake will run the task on a serverless compute pool, billed per second.

How many tasks can I run simultaneously?

Each account supports thousands of tasks. Concurrency is limited only by warehouse size and credit budget.

Where do task logs live?

Use ACCOUNT_USAGE.TASK_HISTORY for 365-day history or INFORMATION_SCHEMA.TASK_HISTORY for 14-day granular events.

Want to learn about other SQL terms?

Trusted by top engineers on high-velocity teams
Aryeo Logo
Assort Health
Curri
Rubie Logo
Bauhealth Logo
Truvideo Logo
Welcome to the Galaxy, Guardian!
Oops! Something went wrong while submitting the form.