Schedule a task

Airplane schedules allow you to incrementally automate your work. You might create a script, deploy it to Airplane, and run it manually to start. You can then set up a Schedule to execute tasks on a periodic basis, similar to cron.
  • Schedules are fully managed, so you don't have to worry about your cron server going down or figuring out how to build a distributed cron system.
  • Any task can be scheduled, making it really easy to set up a repeating operation.
  • Tasks are fully audited, so you get a history of every scheduled run.

Before you begin

If you haven't yet, you'll need to create a task that you can schedule. Check out Build a SQL task for a guide.
This will create a task, Search users, that we'll use here as an example.

Creating a schedule from code

You can create a schedule by adding it to the task definition file of a task. Update the task definition from Build a SQL task with a new schedules section:
yaml
Copied
1
# search_users.task.yaml
2
slug: search_users
3
name: Search users
4
parameters:
5
- name: Query
6
slug: query
7
type: shorttext
8
required: false
9
sql:
10
resource: "[Demo DB]"
11
entrypoint: search_users.sql
12
queryArgs:
13
search: "%{{params.query}}%"
14
schedules:
15
daily:
16
cron: 0 0 * * *
17
description: Runs daily at 12am UTC
18
paramValues:
19
query: vip
  • daily is the slug of the schedule. It serves as an identifier.
  • cron is the recurrence of the schedule, specified in Cron syntax.
  • paramValues contains the values you'd typically pass in to the task. In this example, we're querying for "vip" every time.
Don't forget to run airplane deploy search_users.task.yaml to update the task and schedule.

Creating a schedule in the UI

Alternatively, you can create schedules from the UI. To do so, visit the Search users task and select New schedule:
Name and description are optional for schedules, if you'd like to add additional context / notes. Otherwise, you can specify the recurrence itself and any parameters you want to set.
From the UI, you can set a recurrence such as "Every hour at 10 minutes past the hour". Optionally, you can use Cron syntax to configure the recurrence.
Click Create schedule to finish creating your schedule.

Viewing schedules

You can see all schedules from the Schedules page as well from each task / runbook's page. Opening a schedule takes you to the schedule page to see details and recent runs.
From the top schedule menu, you can Execute the schedule manually, Pause or Unpause the schedule, and more:

Wrapping up

That's all you need to do to create schedules on Airplane. Once created, a schedule will automatically queue a run at the configured time, and all scheduled runs are audited and tracked in the Airplane history.