Schedule your Snowflake Notebook to run

You can schedule your Snowflake Notebook to run as a task. Tasks run and execute code within Snowflake. For more information about tasks, see Introduction to tasks.

About scheduling notebook runs

When you create a schedule for running your notebook, Snowsight creates a task to run your notebook on that schedule. This executes the Notebook in a non-interactive mode, cell by cell from top to bottom. This task is owned by the notebook owner role and uses the notebook warehouse to run. By default, failed task runs of the notebook auto-suspend after 10 failures.

Each notebook run starts the notebook and connects it with the notebook warehouse. As a result, the warehouse used by the notebook is resumed and remains active until 15 minutes after the scheduled task completes. See Billing considerations for running Snowflake Notebooks.

Privileges required to run your Notebook on a Schedule

Because the process of running a notebook on a schedule creates and executes a task, you must use a role that has the following privileges:

Privilege

Object

EXECUTE TASK

Account

USAGE

Database containing the notebook

USAGE, CREATE TASK

Schema containing the notebook

Schedule your notebook

To schedule your notebook to run, create a task by doing the following:

Note

You must use a role granted the CREATE TASK and EXECUTE TASK privileges. See required privileges section for a complete list.

  1. Select Projects » Notebooks.

  2. Locate and select the notebook that you want to schedule.

  3. In the notebook, select the schedule button, then Create schedule.

    Scheduler button at the top right corner.

    The Schedule a notebook run dialog appears.

  4. For Schedule name, enter a name for the notebook schedule. This is used as the name of the task that runs the notebook.

  5. For Frequency, select a frequency at which to run the notebook (for example, Daily).

  6. Depending on the frequency that you select, adjust the Scheduled time and other options to match when you want the notebook to run.

  7. Review the preview of the schedule, and select Create.

A task is created that schedules your notebook to run.

Manage notebook schedules

Once you create schedules for your notebook, you can view and make edits to the schedules via the task list for the schema that the notebook is in.

  1. Select Projects » Notebooks.

  2. Locate and select the notebook that you want to manage schedules for.

  3. In the notebook, select the schedule button, then View schedules. This displays a table of all tasks contained in the schema that the notebook is in.

  4. Use the vertical ellipsis more actions for worksheet menu on the task that runs your notebook and select an action.

You can make edits such as changing the time or frequency of the schedule, and suspending or dropping the task completely. See Introduction to tasks for more details on managing tasks.

Manage past scheduled notebook runs

After your notebook runs as scheduled, you can review the run history for the notebook:

  1. Select Projects » Notebooks.

  2. Locate and select the notebook that you want to schedule.

  3. In the notebook, select the schedule button, then View run history.

    The Run History dialog for your notebook appears.

  4. You can review the run history for the notebook, including run activity generated by the scheduled task or an API. Notebook runs performed by a user are not included. You can review the following details:

    • Trigger: The name of the task that caused the notebook to run.

    • Last Ran: The timestamp of the last scheduled run of the notebook.

    • Status: The status of the task that ran.

    • Duration: The length of time it took to run the notebook.

    • Results: A link to the results of the notebook run. The results are read-only and the notebook cells cannot be edited. You can select Edit current notebook to open and edit the current version of the notebook.

  5. Optionally select View all tasks in schema to see a table of all tasks contained in the schema.

  6. Select Done to return to your notebook.

For more information on viewing task history, see Viewing the task history for your account.

Using your own Scheduler

Some customers may prefer running the Notebook using their own scheduling tool like Airflow. To do so, they can execute the following command:

EXECUTE NOTEBOOK DB.SCHEMA.NOTEBOOK_NAME();
Copy

This executes the Notebook cell by cell from top to bottom. The results are accessible in the Notebook’s run history section.

Limitations

  • The run history for your scheduled notebooks is limited to the last 7 days.

  • If a scheduled notebook run results in a error, then that run is not available in the run history. Try running the notebook manually to see where the error occured.

  • Changing the name of a notebook running as a scheduled task may cause an error in the task. You can manually edit the task using the CREATE TASK command to call the notebook with the changed name.